From 7b12dff3e662d4bfc19ebbc553c4fea7b028e329 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Sun, 28 Jun 2026 22:20:28 +0000 Subject: [PATCH] test(#5121): make auth-failure tests host-independent The 4 terminal-auth-failure tests assert an unrecoverable 401 surfaces an apperror / persisted _error turn. The settlement path first attempts the #1401 credential self-heal, which reads ~/.hermes/auth.json. On a host with populated credentials, self-heal can succeed and retry the mock agent, swallowing the error the test expects -- so the result depended on host credentials (green on CI / Windows with no creds, red on a live agent box). Add an autouse fixture that forces _attempt_credential_self_heal to a no-op so every host exercises the unrecoverable-failure path. The one test that verifies a successful retry already patches the symbol in its own body, so it is unaffected. Co-authored-by: rodboev --- ..._issue5121_provider_auth_terminal_error.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_issue5121_provider_auth_terminal_error.py b/tests/test_issue5121_provider_auth_terminal_error.py index a44ad0b9..ef54a5eb 100644 --- a/tests/test_issue5121_provider_auth_terminal_error.py +++ b/tests/test_issue5121_provider_auth_terminal_error.py @@ -55,6 +55,26 @@ def _isolate_agent_locks(): config.SESSION_AGENT_LOCKS.clear() +@pytest.fixture(autouse=True) +def _neutralize_credential_self_heal(monkeypatch): + """Make the 401 self-heal path a deterministic no-op by default. + + The terminal-auth-failure tests assert that an unrecoverable 401 surfaces + an ``apperror`` / persisted ``_error`` turn. The streaming settlement path + first tries ``_attempt_credential_self_heal`` (#1401), which calls + ``read_auth_json()``. On a host with a populated ``~/.hermes/auth.json`` + (e.g. a developer's real Hermes box) self-heal can succeed and silently + retry the mock agent, swallowing the error the test expects — so the + outcome would depend on host credentials. CI / Windows boxes have no such + credentials, which is why the tests pass there but fail on a live agent + host. Force self-heal off by default so every host exercises the + unrecoverable-failure path; the one test that intentionally verifies a + successful retry patches this symbol explicitly inside its own body. + """ + monkeypatch.setattr(streaming, "_attempt_credential_self_heal", lambda *a, **k: None) + yield + + @pytest.fixture(autouse=True) def _mock_hermes_modules(monkeypatch): fake_runtime_module = types.ModuleType("hermes_cli.runtime_provider")