Guard: genormaliseerd pad
@@ -65,7 +65,7 @@ def project_dir(environ):
65
65
f'dat zou de hele website overschrijven.')
66
66
if root and root not in ('/', '.') and norm.startswith('/') and not norm.startswith(root + '/'):
67
67
raise DeployGuardError(f'DEPLOY GEBLOKKEERD: {PROJECT_VAR} ligt niet onder {ROOT_VAR}.')
68
return value
68
return norm
69
69
70
70
71
71
def main(environ=None):
@@ -65,7 +65,7 @@ def project_dir(environ):65
f'dat zou de hele website overschrijven.')65
f'dat zou de hele website overschrijven.')66
if root and root not in ('/', '.') and norm.startswith('/') and not norm.startswith(root + '/'):66
if root and root not in ('/', '.') and norm.startswith('/') and not norm.startswith(root + '/'):67
raise DeployGuardError(f'DEPLOY GEBLOKKEERD: {PROJECT_VAR} ligt niet onder {ROOT_VAR}.')67
raise DeployGuardError(f'DEPLOY GEBLOKKEERD: {PROJECT_VAR} ligt niet onder {ROOT_VAR}.')68
return value68
return norm69
69
70
70
71
def main(environ=None):71
def main(environ=None):@@ -105,6 +105,7 @@ class DeployGuardTests(unittest.TestCase):
105
105
self.assertEqual(project_dir(env),'/domains/projects.timfalken.com/public_html/verhaaltjesboek')
106
106
self.assertIn('cd "/domains/projects.timfalken.com/public_html/verhaaltjesboek"',deployment_commands(env,ROOT/'web'))
107
107
self.assertEqual(project_dir(dict(self.BASE,projectftp='verhaaltjesboek')),'verhaaltjesboek')
108
self.assertEqual(project_dir(dict(self.BASE,timftproot='/r/',projectftp='$timftproot/vb/')),'/r/vb')
108
109
109
110
def test_cli_exit_code_and_no_values(self):
110
111
import io,contextlib
@@ -105,6 +105,7 @@ class DeployGuardTests(unittest.TestCase):105
self.assertEqual(project_dir(env),'/domains/projects.timfalken.com/public_html/verhaaltjesboek')105
self.assertEqual(project_dir(env),'/domains/projects.timfalken.com/public_html/verhaaltjesboek')106
self.assertIn('cd "/domains/projects.timfalken.com/public_html/verhaaltjesboek"',deployment_commands(env,ROOT/'web'))106
self.assertIn('cd "/domains/projects.timfalken.com/public_html/verhaaltjesboek"',deployment_commands(env,ROOT/'web'))107
self.assertEqual(project_dir(dict(self.BASE,projectftp='verhaaltjesboek')),'verhaaltjesboek')107
self.assertEqual(project_dir(dict(self.BASE,projectftp='verhaaltjesboek')),'verhaaltjesboek')108
self.assertEqual(project_dir(dict(self.BASE,timftproot='/r/',projectftp='$timftproot/vb/')),'/r/vb')108
109
109
def test_cli_exit_code_and_no_values(self):110
def test_cli_exit_code_and_no_values(self):110
import io,contextlib111
import io,contextlib