Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(proxy): model missing organizations in MCP auth fixtures

jesus1b69a5b0a450
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 90ce821d62e..a0fb76349b2 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
@@ -5739,9 +5739,15 @@ class TestMCPDcrBridgeDelegateAdmission:
prisma and are swallowed (``_safe_fetch`` / the SCIM gate's fail-open), so their checks
skip. Yields the ``get_key_object`` mock so callers can assert the sealed ``key_hash`` was
the reload key."""
+ from litellm.proxy.auth.auth_checks import OrganizationNotFoundError
+
get_key_object = AsyncMock(return_value=return_value, side_effect=side_effect)
+ get_org_object = AsyncMock(side_effect=OrganizationNotFoundError("Organization doesn't exist in db."))
patchers = [
patch("litellm.proxy.auth.auth_checks.get_key_object", get_key_object),
+ patch( # test-quality-ok: central auth now resolves org limits; this fixture models a missing org row
+ "litellm.proxy.auth.user_api_key_auth.get_org_object", get_org_object
+ ),
patch("litellm.proxy.proxy_server.prisma_client", MagicMock()),
patch("litellm.proxy.proxy_server.user_api_key_cache", MagicMock()),
]
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
index aa45b2f6793..200df078e00 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
@@ -11870,9 +11870,13 @@ async def test_oauth_credential_write_keeps_virtual_key_permissions(
from litellm.proxy._experimental.mcp_server import mcp_server_manager
from litellm.proxy._experimental.mcp_server.bridge_token_flow import authorize_oauth_credential_request
from litellm.proxy._types import UserAPIKeyAuth, hash_token
- from litellm.proxy.auth.auth_checks import jwt_key_mapping_cache_key
+ from litellm.proxy.auth.auth_checks import OrganizationNotFoundError, jwt_key_mapping_cache_key
handler, signing_key = jwt_oauth_identity
+ monkeypatch.setattr(
+ "litellm.proxy.auth.user_api_key_auth.get_org_object",
+ AsyncMock(side_effect=OrganizationNotFoundError("Organization doesn't exist in db.")),
+ )
key: Final = "sk-oauth-permission-test"
hashed: Final = hash_token(key)
credential: Final = UserAPIKeyAuth(