(bugfix) Quote remote preflight shell commands

Pass remote rsync and source-root preflight checks as a single quoted
shell command to SSH so the remote shell evaluates command -v and test
expressions reliably.

Refs #45
This commit is contained in:
2026-05-21 15:44:46 +02:00
parent 833edb2466
commit 3fb8209aef
2 changed files with 10 additions and 6 deletions

View File

@@ -1100,6 +1100,10 @@ class ViewTests(TestCase):
self.assertContains(response, "Remote rsync")
self.assertContains(response, "Remote source root")
self.assertEqual(run.call_count, 3)
commands = [call.kwargs["args"] if "args" in call.kwargs else call.args[0] for call in run.call_args_list]
self.assertEqual(commands[1][-1], "sh -lc 'command -v rsync >/dev/null'")
self.assertEqual(commands[2][-1], "sh -lc 'test -e / && test -r /'")
self.assertNotIn("sh", commands[2][commands[2].index("root@web-01.example.test") + 1 : -1])
host.refresh_from_db()
self.assertTrue(host.config["last_preflight"]["ok"])
self.assertEqual(host.config["last_preflight"]["target"], "root@web-01.example.test")