test: stabilize quick-command redaction test against xdist ordering

agent.redact._REDACT_ENABLED is snapshotted at import time from
HERMES_REDACT_SECRETS env. Under xdist a prior test in the same worker
can flip it, so test_exec_command_output_is_redacted was order-dependent.
Pin it via monkeypatch like test_terminal_output_transform_still_runs_strip_and_redact does.
This commit is contained in:
Teknium1 2026-05-10 22:05:08 -07:00 committed by Teknium
parent f6736ced81
commit 28b4fe6007

View file

@ -179,10 +179,15 @@ class TestGatewayQuickCommands:
"Quick command leaked OPENROUTER_API_KEY — exec runs without env sanitization"
@pytest.mark.asyncio
async def test_exec_command_output_is_redacted(self):
async def test_exec_command_output_is_redacted(self, monkeypatch):
"""Quick command output must redact sensitive patterns before returning."""
from gateway.run import GatewayRunner
# Ensure redaction is active regardless of host HERMES_REDACT_SECRETS state
# or test ordering (the module snapshots env at import time, so other
# tests in the same xdist worker can flip the flag).
monkeypatch.setattr("agent.redact._REDACT_ENABLED", True)
runner = GatewayRunner.__new__(GatewayRunner)
runner.config = {"quick_commands": {"token": {"type": "exec", "command": "echo sk-ant-api03-supersecretkey1234567890"}}}
runner._running_agents = {}