test(auth): update nous jwt-only expectations

This commit is contained in:
Robin Fernandes
2026-05-29 02:24:48 -07:00
committed by kshitij
parent 7e958dafc2
commit 4e4984a11a
4 changed files with 33 additions and 16 deletions
+18 -1
View File
@@ -4,6 +4,8 @@ and handles responses properly for all supported providers.
Ensures changes to one provider path don't silently break another.
"""
import base64
import json
import sys
import types
from types import SimpleNamespace
@@ -35,6 +37,17 @@ def _tool_defs(*names):
]
def _fake_invoke_jwt() -> str:
def _part(payload):
raw = json.dumps(payload, separators=(",", ":")).encode("utf-8")
return base64.urlsafe_b64encode(raw).decode("ascii").rstrip("=")
return (
f"{_part({'alg': 'none', 'typ': 'JWT'})}."
f"{_part({'scope': 'inference:invoke', 'exp': 4102444800})}.sig"
)
class _FakeOpenAI:
def __init__(self, **kw):
self.api_key = kw.get("api_key", "test")
@@ -925,7 +938,11 @@ class TestAuxiliaryClientProviderPriority:
def test_nous_when_no_openrouter(self, monkeypatch):
monkeypatch.delenv("OPENROUTER_API_KEY", raising=False)
from agent.auxiliary_client import get_text_auxiliary_client
with patch("agent.auxiliary_client._read_nous_auth", return_value={"access_token": "nous-tok"}), \
nous_auth = {
"access_token": _fake_invoke_jwt(),
"scope": "inference:invoke",
}
with patch("agent.auxiliary_client._read_nous_auth", return_value=nous_auth), \
patch("agent.auxiliary_client.OpenAI") as mock, \
patch("hermes_cli.models.get_nous_recommended_aux_model", return_value=None):
client, model = get_text_auxiliary_client()