Allow unauthenticated root probes

This commit is contained in:
Alishahryar1
2026-05-10 16:02:45 -07:00
parent e386a3c8aa
commit f9fc614563
2 changed files with 22 additions and 2 deletions
+2 -2
View File
@@ -207,8 +207,8 @@ async def root(
@router.api_route("/", methods=["HEAD", "OPTIONS"])
async def probe_root(_auth=Depends(require_api_key)):
"""Respond to compatibility probes for the root endpoint."""
async def probe_root():
"""Respond to unauthenticated local compatibility probes for the root endpoint."""
return _probe_response("GET, HEAD, OPTIONS")
+20
View File
@@ -73,3 +73,23 @@ def test_anthropic_auth_token_applies_to_models_endpoint():
assert "data" in r.json()
app.dependency_overrides.clear()
def test_root_get_requires_auth_but_root_probes_are_public():
client = TestClient(app)
settings = Settings()
settings.anthropic_auth_token = "root-token"
app.dependency_overrides[get_settings] = lambda: settings
response = client.get("/")
assert response.status_code == 401
head = client.head("/")
assert head.status_code == 204
assert head.headers["Allow"] == "GET, HEAD, OPTIONS"
options = client.options("/")
assert options.status_code == 204
assert options.headers["Allow"] == "GET, HEAD, OPTIONS"
app.dependency_overrides.clear()