Merge remote-tracking branch 'origin/main' into fix/lldp-keyvalue
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 12s
driver / types (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 57s
driver / lowest (pull_request) Successful in 31s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Successful in 2m44s
driver / publish (pull_request) Skipped

This commit is contained in:
Christian Manivong committed 2026-11-02 11:08:11 +01:00
commit 7259c842e3
5 files changed
+60 -3

No files matched your search

+13
View File
@@ -77,3 +77,16 @@ def test_a_token_only_login_sends_no_empty_password(client): # noqa: F811
)._node_ssh()
assert "password" not in client.connected_with
@pytest.mark.parametrize(
"args",
[{"ssh_private_key_str": _ed25519_pem()}, {"ssh_password": "ssh-pw"}, {}],
ids=["key", "ssh-password", "api-password"],
)
def test_only_the_given_credentials_log_in(client, args): # noqa: F811
"""Neither the keys in the worker's own ~/.ssh nor an SSH agent it reaches (#48)."""
ProxmoxDriver("10.0.0.9", "root", "api-s3cret", optional_args=args)._node_ssh()
assert client.connected_with["look_for_keys"] is False
assert client.connected_with["allow_agent"] is False
+27
View File
@@ -1501,3 +1501,30 @@ def test_a_checksum_algorithm_outside_the_known_ones_is_refused():
)
assert not any("reboot" in c.args[0] for c in mixin._run_node_command.call_args_list)
# ---------------------------------------------------------------------------
# The cloud-init snippet's path in a root shell command (#47)
# ---------------------------------------------------------------------------
def test_a_snippet_storage_path_stays_one_argument(tmp_path, monkeypatch):
storage = tmp_path / "a b;reboot;$(reboot)"
mixin = _hostile_shell(tmp_path, monkeypatch)
mixin._write_snippet(str(storage), "101-user-data.yaml", "#cloud-config\n")
assert not (tmp_path / "injected").exists()
assert (storage / "snippets" / "101-user-data.yaml").read_text() == "#cloud-config\n"
@pytest.mark.parametrize(
"filename", ["x;reboot;.yaml", "../../etc/cron.d/x", "a b.yaml", "$(reboot).yaml", ""]
)
def test_a_snippet_name_that_is_not_a_plain_file_name_is_refused(filename):
mixin = ProxmoxVMProvisionMixin()
mixin._run_node_command = MagicMock(return_value="")
with pytest.raises(ValueError, match="snippet"):
mixin._write_snippet("/var/lib/vz", filename, "#cloud-config\n")
mixin._run_node_command.assert_not_called()