test(models): pin lookalike hosts to the generic OpenAI branch (#4272)

#4159 (4b0a977) made build_models_url insert /v1 for path-less bases, so
the TestBuildersRejectLookalikeHosts model assertions that expected
/models started failing and turned the pytest gate red on dev.

Both the generic OpenAI branch and the real Anthropic branch now end in
/v1/models, so a URL-only assertion no longer proves a lookalike host
dodged the Anthropic/Ollama branch. Assert _detect_provider == "openai"
directly and keep the /v1/models expectation.
This commit is contained in:
Ashvin
2026-06-15 18:13:33 +05:30
committed by GitHub
parent cd02ac7ef6
commit 514d345334
+7 -2
View File
@@ -107,7 +107,10 @@ class TestBuildersRejectLookalikeHosts:
assert build_chat_url("https://notanthropic.com") == "https://notanthropic.com/chat/completions"
def test_lookalike_anthropic_models_is_openai(self):
assert build_models_url("https://anthropic.com.evil.com") == "https://anthropic.com.evil.com/models"
# Must hit the generic OpenAI branch, not Anthropic — assert the
# provider directly since both branches now end in /v1/models.
assert llm_core._detect_provider("https://anthropic.com.evil.com") == "openai"
assert build_models_url("https://anthropic.com.evil.com") == "https://anthropic.com.evil.com/v1/models"
def test_anthropic_domain_in_path_is_openai(self):
assert build_chat_url("https://myproxy.internal/anthropic.com/v1") == "https://myproxy.internal/anthropic.com/v1/chat/completions"
@@ -119,7 +122,9 @@ class TestBuildersRejectLookalikeHosts:
assert build_chat_url("https://notollama.com") == "https://notollama.com/chat/completions"
def test_lookalike_ollama_models_is_openai(self):
assert build_models_url("https://notollama.com") == "https://notollama.com/models"
# Must hit the generic OpenAI branch, not Ollama.
assert llm_core._detect_provider("https://notollama.com") == "openai"
assert build_models_url("https://notollama.com") == "https://notollama.com/v1/models"
class TestBuildersLocalAndDockerEndpoints: