From 527c927b15896f0999453cf93b4540f8ea898b36 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 17:21:50 +0000 Subject: [PATCH] test(proxy): cover Microsoft SSO pagination limit --- .../proxy/management_endpoints/test_ui_sso.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py b/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py index 92470fb5e08..29b909a3cf3 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py +++ b/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py @@ -477,6 +477,11 @@ async def test_get_group_ids_from_service_principal_follows_next_link(): "principalId": "user-1", "principalDisplayName": "User 1", }, + { + "principalType": "Group", + "principalId": None, + "principalDisplayName": "Invalid Group", + }, ], "@odata.nextLink": next_link, } @@ -516,6 +521,27 @@ async def test_get_group_ids_from_service_principal_follows_next_link(): ] +@pytest.mark.asyncio +async def test_get_group_ids_from_service_principal_stops_at_page_limit(): + response = MagicMock() + response.json.return_value = { + "value": [], + "@odata.nextLink": "https://graph.microsoft.com/v1.0/next-page", + } + async_client = MagicMock() + async_client.get = AsyncMock(return_value=response) + + group_ids, teams = await MicrosoftSSOHandler.get_group_ids_from_service_principal( + service_principal_id="sp-123", + async_client=async_client, + access_token="mock_token", + ) + + assert group_ids == [] + assert teams == [] + assert async_client.get.await_count == MicrosoftSSOHandler.MAX_GRAPH_API_PAGES + + def test_get_group_ids_from_graph_api_response(): # Arrange mock_response = MicrosoftGraphAPIUserGroupResponse(