test(proxy): cover custom MCP budget message

This commit is contained in:
jacksonriding 2026-08-15 12:19:11 +10:00
parent 832eb193ab
commit 72aa5b0b1a

View file

@ -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