Skip to content

The agent that grows with you

test: TestSessionTokenInjection moves to the token sibling's test file

ethernete4f03d406367
diff --git a/tests/hermes_cli/test_dashboard_session_token_file.py b/tests/hermes_cli/test_dashboard_session_token_file.py
index 07f16824e6d..b5e42679702 100644
--- a/tests/hermes_cli/test_dashboard_session_token_file.py
+++ b/tests/hermes_cli/test_dashboard_session_token_file.py
@@ -1,5 +1,7 @@
"""The dashboard session token resolves from the environment, or a file it names."""
+from unittest.mock import patch
+
import pytest
@@ -60,3 +62,23 @@ def test_no_source_mints_a_token(monkeypatch):
monkeypatch.delenv("HERMES_DASHBOARD_SESSION_TOKEN", raising=False)
assert len(st.resolve_session_token()) > 0
+
+
+class TestSessionTokenInjection:
+ """The desktop shell mints HERMES_DASHBOARD_SESSION_TOKEN and signs its
+ /api + /api/ws calls with it. The backend must adopt that token, else every
+ desktop request 401s ("gateway is offline"). A main-merge once silently
+ dropped this read — this guards the contract, not a literal value.
+ """
+
+ def test_honors_injected_token(self, monkeypatch):
+ import hermes_cli.web_server as ws
+ import hermes_cli.web_server_session_token as st
+
+ original_app = ws.app
+ original_token = ws._SESSION_TOKEN
+ monkeypatch.setenv("HERMES_DASHBOARD_SESSION_TOKEN", "desktop-seeded-token")
+ assert st.resolve_session_token() == "desktop-seeded-token"
+ # No module reload: the loaded app and its adopted token are untouched.
+ assert ws.app is original_app
+ assert ws._SESSION_TOKEN == original_token
diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.py
index 767103ab472..2cefa97983b 100644
--- a/tests/hermes_cli/test_web_server.py
+++ b/tests/hermes_cli/test_web_server.py
@@ -193,24 +193,6 @@ class TestRedactKey:
assert redact_key("short") == "***"
-class TestSessionTokenInjection:
- """The desktop shell mints HERMES_DASHBOARD_SESSION_TOKEN and signs its
- /api + /api/ws calls with it. The backend must adopt that token, else every
- desktop request 401s ("gateway is offline"). A main-merge once silently
- dropped this read — this guards the contract, not a literal value.
- """
-
- def test_honors_injected_token(self, monkeypatch):
- import hermes_cli.web_server as ws
- import hermes_cli.web_server_session_token as st
-
- original_app = ws.app
- original_token = ws._SESSION_TOKEN
- monkeypatch.setenv("HERMES_DASHBOARD_SESSION_TOKEN", "desktop-seeded-token")
- assert st.resolve_session_token() == "desktop-seeded-token"
- # No module reload: the loaded app and its adopted token are untouched.
- assert ws.app is original_app
- assert ws._SESSION_TOKEN == original_token
def test_session_token_resolution_preserves_loaded_app_auth(self, monkeypatch):
@@ -2677,7 +2659,6 @@ CONFIG_SCHEMA = ProviderConfigSchema(
assert _is_anthropic_frontier_tier(None) is False
-
# ---------------------------------------------------------------------------
# _build_schema_from_config tests
# ---------------------------------------------------------------------------