From 6bcba46dda1ffd8dcba33e5b19c57f1d2e66b5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaeyeon=20Kim=28=EA=B9=80=EC=9E=AC=EC=97=B0=29?= Date: Tue, 3 Mar 2026 06:57:54 +0100 Subject: [PATCH] fix: set mock status_code in JWT OIDC discovery tests (#22361) The _resolve_jwks_url method checks response.status_code != 200, but MagicMock returns a MagicMock object for status_code which is always truthy (!= 200). Explicitly set mock_response.status_code = 200 so the tests exercise the intended code path. Co-authored-by: Claude Opus 4.6 --- tests/test_litellm/proxy/auth/test_handle_jwt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_litellm/proxy/auth/test_handle_jwt.py b/tests/test_litellm/proxy/auth/test_handle_jwt.py index 8418dde5e9..3c19097427 100644 --- a/tests/test_litellm/proxy/auth/test_handle_jwt.py +++ b/tests/test_litellm/proxy/auth/test_handle_jwt.py @@ -1559,6 +1559,7 @@ async def test_resolve_jwks_url_caches_resolved_jwks_uri(): jwks_url = "https://login.microsoftonline.com/tenant/discovery/keys" mock_response = MagicMock() + mock_response.status_code = 200 mock_response.json.return_value = {"jwks_uri": jwks_url} with patch.object(handler.http_handler, "get", new_callable=AsyncMock, return_value=mock_response) as mock_get: @@ -1587,6 +1588,7 @@ async def test_resolve_jwks_url_raises_if_no_jwks_uri_in_discovery_doc(): discovery_url = "https://example.com/.well-known/openid-configuration" mock_response = MagicMock() + mock_response.status_code = 200 mock_response.json.return_value = {"issuer": "https://example.com"} # no jwks_uri with patch.object(handler.http_handler, "get", new_callable=AsyncMock, return_value=mock_response):