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]

Simplify SCIM tests to focus on core issue

Haji Akhundov8871a5670be8
diff --git a/tests/test_litellm/proxy/management_endpoints/scim/test_scim_transformations.py b/tests/test_litellm/proxy/management_endpoints/scim/test_scim_transformations.py
index 3217a1c4480..be9c79911d0 100644
--- a/tests/test_litellm/proxy/management_endpoints/scim/test_scim_transformations.py
+++ b/tests/test_litellm/proxy/management_endpoints/scim/test_scim_transformations.py
@@ -232,13 +232,11 @@ class TestScimTransformations:
@pytest.mark.asyncio
async def test_transform_user_with_uuid_as_email(self, mock_prisma_client):
"""
- Test that users with UUID in user_email field (from old bug)
- don't cause validation errors when transforming to SCIM format.
+ Test that users with UUID in user_email don't cause validation errors.
This tests the defensive fix that validates email contains '@' before creating SCIMUserEmail.
"""
mock_client, mock_find_unique = mock_prisma_client
-
- # Create a user with UUID in user_email (simulating the bug scenario)
+
user_with_uuid_email = LiteLLM_UserTable(
user_id="21df4e37-2f38-4f2e-a21b-c33cb939ff5b",
user_email="21df4e37-2f38-4f2e-a21b-c33cb939ff5b", # UUID as email (bug scenario)
@@ -248,56 +246,45 @@ class TestScimTransformations:
updated_at=None,
metadata={},
)
-
- mock_find_unique.return_value = None # No teams to look up
-
+
+ mock_find_unique.return_value = None
+
with patch("litellm.proxy.proxy_server.prisma_client", mock_client):
- # This should not raise a validation error
scim_user = await ScimTransformations.transform_litellm_user_to_scim_user(
user_with_uuid_email
)
-
- # Verify the user was transformed successfully
+
assert scim_user.id == user_with_uuid_email.user_id
- # Email should not be in emails array since it's a UUID (no '@' sign)
assert scim_user.emails is None or len(scim_user.emails) == 0
- # userName should fall back to default since email is invalid
- assert scim_user.userName == ScimTransformations.DEFAULT_SCIM_DISPLAY_NAME
@pytest.mark.asyncio
async def test_transform_user_with_none_email(self, mock_prisma_client):
"""
- Test that users created via group membership (with user_email=None)
- are transformed correctly without errors.
+ Test that users with user_email=None are transformed correctly.
This tests the root cause fix.
"""
mock_client, mock_find_unique = mock_prisma_client
-
- # Create a user with None email (correct behavior after fix)
+
user_with_none_email = LiteLLM_UserTable(
user_id="user-from-group",
- user_email=None, # None instead of UUID (after fix)
+ user_email=None,
user_alias=None,
teams=[],
created_at=None,
updated_at=None,
- metadata={"created_via": "scim_group_membership"},
+ metadata={},
)
-
- mock_find_unique.return_value = None # No teams to look up
-
+
+ mock_find_unique.return_value = None
+
with patch("litellm.proxy.proxy_server.prisma_client", mock_client):
- # This should not raise any errors
scim_user = await ScimTransformations.transform_litellm_user_to_scim_user(
user_with_none_email
)
-
- # Verify the user was transformed successfully
+
assert scim_user.id == user_with_none_email.user_id
- # Email should not be in emails array
assert scim_user.emails is None or len(scim_user.emails) == 0
- # userName should use default since no email
- assert scim_user.userName == ScimTransformations.DEFAULT_SCIM_DISPLAY_NAME
+
class TestSCIMPatchOperations: