mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(honcho): CLI credential guard rejects self-hosted baseUrl configs
_resolve_api_key() only checks for apiKey / HONCHO_API_KEY, so all CLI subcommands (identity --show, status, migrate, etc.) bail with "No API key configured" on self-hosted instances that use baseUrl without an API key. Return "local" when baseUrl or HONCHO_BASE_URL is set, matching the client.py behavior that already handles this case for the SDK. Tested on: macOS, self-hosted Honcho (Docker, localhost:8000).
This commit is contained in:
parent
ab0d8c9a1c
commit
0a40c381b9
2 changed files with 51 additions and 2 deletions
|
|
@ -3,6 +3,45 @@
|
|||
from types import SimpleNamespace
|
||||
|
||||
|
||||
class TestResolveApiKey:
|
||||
"""Test _resolve_api_key with various config shapes."""
|
||||
|
||||
def test_returns_api_key_from_root(self, monkeypatch):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes")
|
||||
monkeypatch.delenv("HONCHO_API_KEY", raising=False)
|
||||
assert honcho_cli._resolve_api_key({"apiKey": "root-key"}) == "root-key"
|
||||
|
||||
def test_returns_api_key_from_host_block(self, monkeypatch):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes")
|
||||
monkeypatch.delenv("HONCHO_API_KEY", raising=False)
|
||||
cfg = {"hosts": {"hermes": {"apiKey": "host-key"}}, "apiKey": "root-key"}
|
||||
assert honcho_cli._resolve_api_key(cfg) == "host-key"
|
||||
|
||||
def test_returns_local_for_base_url_without_api_key(self, monkeypatch):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes")
|
||||
monkeypatch.delenv("HONCHO_API_KEY", raising=False)
|
||||
monkeypatch.delenv("HONCHO_BASE_URL", raising=False)
|
||||
cfg = {"baseUrl": "http://localhost:8000"}
|
||||
assert honcho_cli._resolve_api_key(cfg) == "local"
|
||||
|
||||
def test_returns_local_for_base_url_env_var(self, monkeypatch):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes")
|
||||
monkeypatch.delenv("HONCHO_API_KEY", raising=False)
|
||||
monkeypatch.setenv("HONCHO_BASE_URL", "http://10.0.0.5:8000")
|
||||
assert honcho_cli._resolve_api_key({}) == "local"
|
||||
|
||||
def test_returns_empty_when_nothing_configured(self, monkeypatch):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes")
|
||||
monkeypatch.delenv("HONCHO_API_KEY", raising=False)
|
||||
monkeypatch.delenv("HONCHO_BASE_URL", raising=False)
|
||||
assert honcho_cli._resolve_api_key({}) == ""
|
||||
|
||||
|
||||
class TestCmdStatus:
|
||||
def test_reports_connection_failure_when_session_setup_fails(self, monkeypatch, capsys, tmp_path):
|
||||
import plugins.memory.honcho.cli as honcho_cli
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue