From 72aa5b0b1a92459584503910e75dec1c738fce83 Mon Sep 17 00:00:00 2001 From: jacksonriding Date: Sat, 15 Aug 2026 12:19:11 +1000 Subject: [PATCH] test(proxy): cover custom MCP budget message --- .../mcp_server/auth/test_user_api_key_auth_mcp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py b/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py index 52dc91ce24d..9f5ff944b77 100644 --- a/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py +++ b/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py @@ -5671,15 +5671,17 @@ class TestMCPDcrBridgeDelegateAdmission: ) return exc_info.value - async def test_over_budget_admission_surfaces_429_not_401(self): + async def test_over_budget_admission_surfaces_429_not_401(self, monkeypatch): """A validly-authenticated but over-budget identity surfaces the standard pipeline's 429, not a misleading 401. Flattening budget to 401 told the caller their credential was invalid, which on a DCR client reads as broken auth and triggers a re-authorize that cannot fix a budget problem. Regression for the status-flattening finding on the live-policy gate.""" import litellm + monkeypatch.setattr(litellm, "budget_exceeded_error_message", "Allowance reached") mapped = await self._enforce_with_gate_error(litellm.BudgetExceededError(current_cost=10.0, max_budget=1.0)) assert mapped.status_code == 429 + assert mapped.detail == "Allowance reached" async def test_db_outage_during_policy_surfaces_503_not_401(self): """A transient database outage during the live-policy gate surfaces a retryable 503, not a 401