The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(auxiliary): fold the origin cases into existing parametrizations; pin the third cached key
kshitijk4poorc7f6101be982
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.pyindex cc90c7dc4d8..8424e3d64d6 100644--- a/tests/agent/test_auxiliary_client.py+++ b/tests/agent/test_auxiliary_client.py@@ -4826,16 +4826,17 @@ class TestCustomEndpointApiKeyInheritance:assert model == "aux-model"assert (client.api_key == "sk-main-config-key") is inherits- @pytest.mark.parametrize("aux_base_url,explicit_key", [- ("https://gw.example.com/v1", None), (None, None),- ("https://gw.example.com/v1", " "), (None, " "), (None, "sk-explicit-aux"),+ @pytest.mark.parametrize("aux_base_url,explicit_key,expected_third", [+ ("https://gw.example.com/v1", None, "no-key-required"), (None, None, None),+ ("https://gw.example.com/v1", " ", "no-key-required"), (None, " ", None), (None, "sk-explicit-aux", None),], ids=["explicit-base-url", "runtime-endpoint", "explicit-base-url-blank-key","runtime-endpoint-blank-key", "runtime-endpoint-explicit-key"])- def test_cached_client_carries_only_the_live_main_credential(self, monkeypatch, aux_base_url, explicit_key):+ def test_cached_client_carries_only_the_live_main_credential(self, monkeypatch, aux_base_url, explicit_key, expected_third):"""Auxiliary requests go through the client cache: a client built while one runtime was livemust not be served, carrying that runtime's key, once the live runtime changed. The cache andthe client build agree on when the main credential is borrowed: a blank explicit key is- keyless, and the runtime-endpoint shape never uses the explicit key."""+ keyless, and the runtime-endpoint shape never uses the explicit key: with a keyless runtime+ it has no credential at all, so no client is built."""import agent.auxiliary_client as auxmonkeypatch.delenv("OPENAI_API_KEY", raising=False)@@ -4855,7 +4856,7 @@ class TestCustomEndpointApiKeyInheritance:aux.clear_runtime_main()assert served[:2] == ["sk-first-session", "sk-second-session"]- assert served[2] not in ("sk-first-session", "sk-second-session")+ assert served[2] == expected_third # keyless explicit endpoint → placeholder; runtime endpoint → no clientclass TestNoProgressTimeoutTaskConfigGating:diff --git a/tests/hermes_cli/test_runtime_provider_resolution.py b/tests/hermes_cli/test_runtime_provider_resolution.pyindex dcbfa6dca01..6f28ab339c2 100644--- a/tests/hermes_cli/test_runtime_provider_resolution.py+++ b/tests/hermes_cli/test_runtime_provider_resolution.py@@ -706,9 +706,13 @@ def test_real_openai_key_is_never_routed_or_sent_to_openrouter(monkeypatch):("https://proxy.corp.example/v1", ""),("proxy.corp.example:8080/v1", ""), # scheme-less still names a foreign host("https://openrouter.ai/api/v1", "sk-openai-fallback"),+ ("http://openrouter.ai/api/v1", ""), # same host, http: another origin+ ("https://openrouter.ai:8443/api/v1", ""), # same host, another port+ ("https://openrouter.ai:443/api/v1", "sk-openai-fallback"), # default port spelled out: same origin])def test_openai_key_bound_to_another_host_never_reaches_openrouter(monkeypatch, openai_base_url, expected_key):- """OPENAI_API_KEY is an OpenRouter fallback only while OPENAI_BASE_URL doesn't bind it elsewhere."""+ """OPENAI_API_KEY is an OpenRouter fallback only while OPENAI_BASE_URL doesn't bind it elsewhere:+ a bound key follows its exact origin, so the same hostname over http:// or on another port is elsewhere."""from hermes_cli.runtime_provider_backends import _resolve_openrouter_runtimemonkeypatch.setattr(rp, "_get_model_config", lambda: {})monkeypatch.setenv("OPENAI_BASE_URL", openai_base_url)@@ -722,25 +726,6 @@ def test_openai_key_bound_to_another_host_never_reaches_openrouter(monkeypatch,assert resolved["api_key"] == expected_key[email protected]("openrouter_base_url, inherits", [- ("https://gw.example.com:443/v1", True),- ("http://gw.example.com/v1", False),- ("https://gw.example.com:8443/v1", False),-])-def test_openai_key_follows_only_its_bound_origin(monkeypatch, openrouter_base_url, inherits):- """An OPENAI_BASE_URL-bound OPENAI_API_KEY reaches an OpenRouter mirror only on the identical origin:- the same hostname over http://, or on another port, is a different endpoint."""- monkeypatch.setenv("OPENAI_BASE_URL", "https://gw.example.com/v1")- monkeypatch.setenv("OPENAI_API_KEY", "sk-proxy-bound-key")- monkeypatch.setenv("OPENROUTER_BASE_URL", openrouter_base_url)- monkeypatch.delenv("OPENROUTER_API_KEY", raising=False)-- resolved = rp.resolve_runtime_provider(requested="openrouter")-- assert resolved["base_url"] == openrouter_base_url- assert (resolved["api_key"] == "sk-proxy-bound-key") is inherits--def test_custom_endpoint_uses_saved_config_base_url_when_env_missing(monkeypatch):"""Persisted custom endpoints in config.yaml must still resolve whenOPENAI_BASE_URL is absent from the current environment.