From 04f0d4b545a03694a1b6945b135e59feec1329c0 Mon Sep 17 00:00:00 2001 From: jibanez-staticduo Date: Fri, 18 Sep 2026 13:39:28 +0200 Subject: [PATCH] test: assert sanitized live access errors --- .../proxy/realtime_endpoints/test_call_sessions.py | 5 +++-- tests/test_litellm/proxy/realtime_endpoints/test_live.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_litellm/proxy/realtime_endpoints/test_call_sessions.py b/tests/test_litellm/proxy/realtime_endpoints/test_call_sessions.py index cd139563dc2..89e9c4efe6d 100644 --- a/tests/test_litellm/proxy/realtime_endpoints/test_call_sessions.py +++ b/tests/test_litellm/proxy/realtime_endpoints/test_call_sessions.py @@ -280,8 +280,9 @@ async def test_offer_auth_enforces_session_model_policy_before_upstream( with pytest.raises(ProxyException) as denied: await proxy_realtime_calls(request, Response()) if policy == "personal_models": - assert "user not allowed to access model" in str(denied.value) - assert "forbidden-voice" in str(denied.value) + internal_message = getattr(denied.value, "internal_message", str(denied.value)) + assert "user not allowed to access model" in internal_message + assert "forbidden-voice" in internal_message custom.assert_awaited_once() upstream.assert_not_awaited() if policy == "budget": diff --git a/tests/test_litellm/proxy/realtime_endpoints/test_live.py b/tests/test_litellm/proxy/realtime_endpoints/test_live.py index 4cc8f9dd16a..d4df56345cd 100644 --- a/tests/test_litellm/proxy/realtime_endpoints/test_live.py +++ b/tests/test_litellm/proxy/realtime_endpoints/test_live.py @@ -17,7 +17,7 @@ from litellm.models.project import LiteLLM_ProjectTable from litellm.models.team import LiteLLM_TeamTable from litellm.models.team_membership import LiteLLM_TeamMembership from litellm.models.user import LiteLLM_UserTable -from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy._types import ModelAccessDeniedProxyException, UserAPIKeyAuth from litellm.proxy.realtime_endpoints import live @@ -1132,8 +1132,9 @@ async def test_authorize_enforces_authoritative_personal_user_models(monkeypatch auth = UserAPIKeyAuth(api_key="owner", models=[], user_id="user-only") await live._authorize("voice", auth) - with pytest.raises(Exception, match="user can only access"): + with pytest.raises(ModelAccessDeniedProxyException) as rejected: await live._authorize("backend", auth) + assert "user can only access" in rejected.value.internal_message assert user_loader.await_count == 2 @@ -1153,8 +1154,9 @@ async def test_authorize_enforces_authoritative_organization_models(monkeypatch, auth = UserAPIKeyAuth(api_key="owner", models=[], org_id="org-only") await live._authorize("voice", auth) - with pytest.raises(Exception, match="org can only access"): + with pytest.raises(ModelAccessDeniedProxyException) as rejected: await live._authorize("backend", auth) + assert "org can only access" in rejected.value.internal_message assert org_loader.await_count == 2