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 <rodboev@users.noreply.github.com>
This commit is contained in:
parent
4763c2a9a4
commit
7b12dff3e6
1 changed files with 20 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue