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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(auth): add regression tests for JWTHandler.is_jwt(None)
Ryan Crabbe8e3755931ddb
diff --git a/litellm/proxy/auth/handle_jwt.py b/litellm/proxy/auth/handle_jwt.pyindex 86f7d614b95..48bbd8e2150 100644--- a/litellm/proxy/auth/handle_jwt.py+++ b/litellm/proxy/auth/handle_jwt.py@@ -89,7 +89,7 @@ class JWTHandler:self.leeway = leeway@staticmethod- def is_jwt(token: Optional[str]):+ def is_jwt(token: Optional[str]) -> bool:if token is None:return Falseparts = token.split(".")diff --git a/tests/proxy_unit_tests/test_jwt.py b/tests/proxy_unit_tests/test_jwt.pyindex 24cf15a3214..a5be1a3a42d 100644--- a/tests/proxy_unit_tests/test_jwt.py+++ b/tests/proxy_unit_tests/test_jwt.py@@ -1331,6 +1331,9 @@ def test_jwt_handler_is_jwt_static_method():# Test with empty stringassert JWTHandler.is_jwt("") == False+ # Test with None (missing Authorization header)+ assert JWTHandler.is_jwt(None) == False+@pytest.mark.parametrize("requested_model, should_work",diff --git a/tests/test_litellm/proxy/auth/test_user_api_key_auth.py b/tests/test_litellm/proxy/auth/test_user_api_key_auth.pyindex 81ca758983b..6e000f9c0e3 100644--- a/tests/test_litellm/proxy/auth/test_user_api_key_auth.py+++ b/tests/test_litellm/proxy/auth/test_user_api_key_auth.py@@ -567,6 +567,10 @@ class TestJWTOAuth2Coexistence:assert JWTHandler.is_jwt("Bearer token") is Falseassert JWTHandler.is_jwt("two.parts") is False+ def test_is_jwt_returns_false_for_none(self):+ """None token (missing Authorization header) should not be treated as JWT."""+ assert JWTHandler.is_jwt(None) is False+@pytest.mark.asyncioasync def test_both_enabled_opaque_token_uses_oauth2(self):"""