fix: keep the harness admin password out of the docker exec argv
This commit is contained in:
1 parent
517c675048
commit
72462105f5
2 files changed
+44
-13
No files matched your search
@@ -157,3 +157,27 @@ def test_container_id_candidates_fall_back_to_proc(tmp_path: Path) -> None:
|
||||
|
||||
def test_container_id_candidates_tolerate_missing_files(tmp_path: Path) -> None:
|
||||
assert harness.container_id_candidates({}, proc_root=tmp_path) == []
|
||||
|
||||
|
||||
def test_run_docker_passes_secrets_through_the_environment_not_argv(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
seen: dict[str, object] = {}
|
||||
|
||||
def fake_run(argv: list[str], **kwargs: object) -> object:
|
||||
seen["argv"] = argv
|
||||
seen["env"] = kwargs.get("env")
|
||||
|
||||
class Done:
|
||||
returncode = 0
|
||||
stdout = ""
|
||||
stderr = ""
|
||||
|
||||
return Done()
|
||||
|
||||
monkeypatch.setattr(harness.subprocess, "run", fake_run)
|
||||
harness.run_docker("exec", "-e", "SECRET_VAR", "box", env={"SECRET_VAR": "s3cret-value"})
|
||||
|
||||
assert "s3cret-value" not in " ".join(seen["argv"]) # type: ignore[call-overload]
|
||||
assert seen["env"]["SECRET_VAR"] == "s3cret-value" # type: ignore[index]
|
||||
assert "PATH" in seen["env"] # type: ignore[operator]
|
||||
Reference in new issue
Block a user