Isolate database credentials for agent tests
This commit is contained in:
@@ -12,4 +12,27 @@ def test_aider_command_cannot_mutate_git_configuration_or_send_analytics() -> No
|
||||
assert "--no-analytics" in command
|
||||
assert "--no-auto-commits" in command
|
||||
assert command.count("/dev/null") == 2
|
||||
assert command[-4:] == ["--edit-format", "diff", "--timeout", "60"]
|
||||
assert command[-4:] == ["--edit-format", "diff", "--timeout", "60"]
|
||||
|
||||
|
||||
def test_aider_environment_does_not_include_database_credentials(tmp_path, monkeypatch) -> None:
|
||||
config = settings(workspace_root=tmp_path)
|
||||
workspace = tmp_path / "repo"
|
||||
(workspace / ".git").mkdir(parents=True)
|
||||
monkeypatch.setenv("TEST_DB_PASSWORD", "must-not-reach-aider")
|
||||
captured = {}
|
||||
|
||||
def run(command, **kwargs):
|
||||
captured.update(kwargs["env"])
|
||||
return type("Result", (), {"returncode": 0, "stdout": "ok", "stderr": ""})()
|
||||
|
||||
monkeypatch.setattr("lai_automation.agent.subprocess.run", run)
|
||||
monkeypatch.setattr("lai_automation.agent.os.chown", lambda *args, **kwargs: None)
|
||||
monkeypatch.setattr("lai_automation.agent.pwd.getpwnam", lambda _: type(
|
||||
"Account", (), {"pw_dir": str(tmp_path), "pw_uid": 10001, "pw_gid": 10001}
|
||||
)())
|
||||
|
||||
AiderAgent(config).run(workspace, "fix it")
|
||||
|
||||
assert "TEST_DB_PASSWORD" not in captured
|
||||
assert "DB_PASSWORD" not in captured
|
||||
Reference in New Issue
Block a user