mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
feat(galileo): verify API key via /current_user health check
Call Galileo's current_user endpoint so the UI callback test validates credentials against the provider. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2258cf8cc6
commit
2243efda62
2 changed files with 51 additions and 0 deletions
|
|
@ -124,6 +124,18 @@ class GalileoObserve(CustomLogger):
|
|||
"error_message": "Galileo authentication failed",
|
||||
}
|
||||
|
||||
response = await self.async_httpx_handler.get(
|
||||
url=f"{self.base_url}/current_user",
|
||||
headers=self.headers,
|
||||
)
|
||||
if response.status_code >= 400:
|
||||
return {
|
||||
"status": "unhealthy",
|
||||
"error_message": (
|
||||
f"Galileo API returned HTTP {response.status_code}"
|
||||
),
|
||||
}
|
||||
|
||||
return {
|
||||
"status": "healthy",
|
||||
"message": "Galileo credentials are configured properly",
|
||||
|
|
|
|||
|
|
@ -524,6 +524,45 @@ def test_galileo_get_ingest_request_legacy(monkeypatch):
|
|||
assert payload["traces"][0]["input"] == "hi"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_galileo_async_health_check_success(galileo_v2_env):
|
||||
logger = GalileoObserve()
|
||||
current_user_resp = MagicMock()
|
||||
current_user_resp.status_code = 200
|
||||
|
||||
with patch.object(
|
||||
logger.async_httpx_handler, "get", new_callable=AsyncMock
|
||||
) as mock_get:
|
||||
mock_get.return_value = current_user_resp
|
||||
result = await logger.async_health_check()
|
||||
|
||||
assert result["status"] == "healthy"
|
||||
mock_get.assert_awaited_once_with(
|
||||
url="https://api.galileo.ai/current_user",
|
||||
headers={
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"Galileo-API-Key": "test-api-key",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_galileo_async_health_check_api_error(galileo_v2_env):
|
||||
logger = GalileoObserve()
|
||||
current_user_resp = MagicMock()
|
||||
current_user_resp.status_code = 401
|
||||
|
||||
with patch.object(
|
||||
logger.async_httpx_handler, "get", new_callable=AsyncMock
|
||||
) as mock_get:
|
||||
mock_get.return_value = current_user_resp
|
||||
result = await logger.async_health_check()
|
||||
|
||||
assert result["status"] == "unhealthy"
|
||||
assert "HTTP 401" in result["error_message"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_galileo_ensure_headers_v2_missing_key(monkeypatch):
|
||||
monkeypatch.delenv("GALILEO_API_KEY", raising=False)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue