mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
test(auth): add regression tests for JWTHandler.is_jwt(None)
Add None-token test cases to both proxy_unit_tests and test_litellm to cover the guard added in the previous commit. Also add -> bool return type annotation to is_jwt().
This commit is contained in:
parent
e36ab04a18
commit
8e3755931d
3 changed files with 8 additions and 1 deletions
|
|
@ -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 False
|
||||
parts = token.split(".")
|
||||
|
|
|
|||
|
|
@ -1331,6 +1331,9 @@ def test_jwt_handler_is_jwt_static_method():
|
|||
# Test with empty string
|
||||
assert JWTHandler.is_jwt("") == False
|
||||
|
||||
# Test with None (missing Authorization header)
|
||||
assert JWTHandler.is_jwt(None) == False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"requested_model, should_work",
|
||||
|
|
|
|||
|
|
@ -567,6 +567,10 @@ class TestJWTOAuth2Coexistence:
|
|||
assert JWTHandler.is_jwt("Bearer token") is False
|
||||
assert 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.asyncio
|
||||
async def test_both_enabled_opaque_token_uses_oauth2(self):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue