test(model-switch): cover section-3 no-auth probe; map chimpera author

Salvage follow-up for PR #29575: add regression tests for the section-3
no-api_key /v1/models probe (probes bare endpoints, skips when explicit
models set) and add the contributor AUTHOR_MAP entry.
This commit is contained in:
teknium1 2026-06-16 12:00:16 -07:00 committed by Teknium
parent 1039e90b5e
commit 7493de7fc3
2 changed files with 79 additions and 0 deletions

View file

@ -417,6 +417,7 @@ AUTHOR_MAP = {
"cine.dreamer.one@gmail.com": "LeonSGP43",
"david@nutricraft.ca": "cyb0rgk1tty",
"214562553+cyb0rgk1tty@users.noreply.github.com": "cyb0rgk1tty",
"11052595+chimpera@users.noreply.github.com": "chimpera",
"chris+dora@cmullins.io": "cmullins70",
"zjtan1@gmail.com": "zeejaytan",
"asslaenn5@gmail.com": "Aslaaen",

View file

@ -1044,3 +1044,81 @@ def test_user_provider_override_rejects_mangled_private_models(
assert result.success is False
assert result.error_message == "not found"
# =============================================================================
# Section 3 no-auth live discovery (PR #29575)
# =============================================================================
def test_section3_probes_no_key_endpoint_without_explicit_models(monkeypatch):
"""A providers: entry with no api_key and no explicit models: list should
still probe /v1/models for live discovery mirroring section 4's policy.
Regression for #29575: local self-hosted backends (llama.cpp, Ollama,
vLLM) that don't require auth previously showed an empty/minimal model
list because section 3 gated probing on ``api_url and api_key``.
"""
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
monkeypatch.setattr("hermes_cli.providers.HERMES_OVERLAYS", {})
probed = {}
def _fake_fetch(api_key, api_url):
probed["called"] = True
probed["api_key"] = api_key
probed["api_url"] = api_url
return ["live-model-1", "live-model-2", "live-model-3"]
monkeypatch.setattr("hermes_cli.models.fetch_api_models", _fake_fetch)
user_providers = {
"local-llamacpp": {
"name": "Local llama.cpp",
"api": "http://localhost:8080/v1",
# No api_key, no models list — bare local endpoint.
}
}
providers = list_authenticated_providers(
current_provider="local-llamacpp",
user_providers=user_providers,
custom_providers=[],
max_models=50,
)
assert probed.get("called") is True, "no-key bare endpoint should be probed"
assert probed["api_key"] == ""
row = next(p for p in providers if p["slug"] == "local-llamacpp")
assert row["models"] == ["live-model-1", "live-model-2", "live-model-3"]
assert row["total_models"] == 3
def test_section3_skips_probe_when_no_key_but_explicit_models(monkeypatch):
"""A no-key endpoint WITH an explicit models: list is the user narrowing a
public endpoint to a subset skip live discovery and keep the list."""
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
monkeypatch.setattr("hermes_cli.providers.HERMES_OVERLAYS", {})
def _fail_fetch(api_key, api_url):
raise AssertionError("should not probe when explicit models are set")
monkeypatch.setattr("hermes_cli.models.fetch_api_models", _fail_fetch)
user_providers = {
"public-subset": {
"name": "Public Subset",
"api": "https://ollama.com/v1",
"models": ["only-a", "only-b"],
}
}
providers = list_authenticated_providers(
current_provider="public-subset",
user_providers=user_providers,
custom_providers=[],
max_models=50,
)
row = next(p for p in providers if p["slug"] == "public-subset")
assert row["models"] == ["only-a", "only-b"]
assert row["total_models"] == 2