Files
hermes-webui/tests
Dutch AI Agency b6f6640b17 fix(tests): isolate settings.json writes in #1560 tests to prevent CI bleed
CI failed across test_clarify_unblock + test_gateway_sync (~25 tests, all 401
Unauthorized) because two tests in this module write `password_hash` directly
to the shared TEST_STATE_DIR/settings.json (the path the integration server
reads):

- `test_post_set_password_settings_hash_unchanged_after_409` seeds a sentinel
  hash to verify the 409 short-circuit doesn't overwrite it.
- `test_post_set_password_succeeds_when_env_var_unset` goes through
  save_settings() with `_set_password`, persisting a real hash.

After this module ran, the integration server saw `is_auth_enabled() == True`
and rejected every subsequent request from test_clarify_unblock /
test_gateway_sync with 401.

Fix:
- Add `_restore_settings_file_after_test` autouse fixture that snapshots
  cfg.SETTINGS_FILE before each test and restores it after, so password_hash
  writes don't leak to later tests.
- Remove the misleading module-level `os.environ['HERMES_WEBUI_STATE_DIR']`
  override — api.config.STATE_DIR resolves at import time (already done by
  conftest.py before this module loads), so the override never reached the
  in-process state path it claimed to redirect.
- Add `self.request = None` to FakeHandler so set_auth_cookie's
  `getattr(handler.request, 'getpeercert', None)` probe doesn't AttributeError
  on the success path of `_set_password` once settings are properly cleaned
  between tests (the prior CI pass relied on stale state bouncing the request
  with 401 before set_auth_cookie ran).

Verified locally: 85 tests pass across test_1560_*, test_issue1560_*,
test_clarify_unblock, test_gateway_sync (the previously-affected suites).
2026-05-03 20:59:32 +00:00
..
2026-04-29 19:54:07 -07:00
2026-04-29 17:42:32 -07:00
2026-04-29 17:42:32 -07:00
2026-04-29 21:34:27 -07:00
2026-04-29 21:06:30 -07:00
2026-04-29 17:42:32 -07:00
2026-04-29 17:42:32 -07:00