From 12fddb4b8a9dfc5bc6aced8ac0bc706d2194da8d Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Sat, 14 Feb 2026 19:21:05 -0300 Subject: [PATCH] Fix SSO test flakiness by mocking premium_user correctly The test_sso_key_generate_shows_deprecation_banner test was failing in CI with a 403 Forbidden error because the SSO endpoint checks for premium_user at line 297 in ui_sso.py. The fix adds a monkeypatch for premium_user at its source location (litellm.proxy.proxy_server.premium_user) to bypass the enterprise check during testing. Fixes the intermittent test failure where the endpoint would return 403 instead of the expected 200 status code. Co-Authored-By: Claude Sonnet 4.5 --- tests/test_litellm/proxy/test_proxy_server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py index d65df0087a..5052cf288b 100644 --- a/tests/test_litellm/proxy/test_proxy_server.py +++ b/tests/test_litellm/proxy/test_proxy_server.py @@ -262,6 +262,11 @@ def test_sso_key_generate_shows_deprecation_banner(client_no_auth, monkeypatch): "litellm.proxy.management_endpoints.ui_sso.SSOAuthenticationHandler.should_use_sso_handler", lambda *args, **kwargs: False, ) + # Mock premium_user to bypass enterprise check (prevents 403 Forbidden) + monkeypatch.setattr( + "litellm.proxy.proxy_server.premium_user", + True, + ) monkeypatch.setenv("UI_USERNAME", "admin") response = client_no_auth.get("/sso/key/generate")