Skip to content

fix(tests): set premium_user=True in JWT tests that call user_api_key_auth#21641

Merged
jquinter merged 1 commit intomainfrom
fix/jwt-tests-missing-premium-user-flag
Feb 20, 2026
Merged

fix(tests): set premium_user=True in JWT tests that call user_api_key_auth#21641
jquinter merged 1 commit intomainfrom
fix/jwt-tests-missing-premium-user-flag

Conversation

@jquinter
Copy link
Contributor

Summary

Four JWT tests in tests/proxy_unit_tests/test_jwt.py were failing with:

ValueError: JWT Auth is an enterprise only feature. You must be a LiteLLM Enterprise user...

Because user_api_key_auth gates enable_jwt_auth behind the enterprise license check:

if general_settings.get("enable_jwt_auth", False) is True:
    if premium_user is not True:
        raise ValueError("JWT Auth is an enterprise only feature. ...")

The tests set enable_jwt_auth: True but did not set premium_user = True, causing them to hit the gate instead of testing JWT logic.

Fix

Add setattr(litellm.proxy.proxy_server, "premium_user", True) immediately before the general_settings setattr in each failing test — the same pattern used by PR #21285.

Affected tests:

  • test_team_token_output
  • test_allowed_routes_admin
  • test_allow_access_by_email
  • test_end_user_jwt_auth

Relation to PR #21634

These failures are not related to PR #21634 (which only touches litellm/llms/azure/azure.py). The same test failures are present on main independently.

Test plan

  • test_allow_access_by_email[ishaan@berri.ai-True] passes locally after fix
  • test_end_user_jwt_auth passes locally after fix
  • test_team_token_output and test_allowed_routes_admin require a live DB (CI) — the enterprise gate was the first failure; fixing it unblocks the JWT logic tests

…_auth

JWT auth is an enterprise-only feature. Tests that call user_api_key_auth
with enable_jwt_auth=True must set premium_user=True on the proxy server
to bypass the enterprise gate, otherwise they fail with:

  ValueError: JWT Auth is an enterprise only feature.

This follows the same pattern as PR #21285 (fix/jwt-enterprise-license-test).

Fixed tests:
- test_team_token_output
- test_allowed_routes_admin
- test_allow_access_by_email
- test_end_user_jwt_auth

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 20, 2026 3:33am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

Fixed four failing JWT tests by setting premium_user=True before enabling JWT auth. The tests were hitting an enterprise license gate in user_api_key_auth that prevents JWT authentication without a premium license.

Changes:

Tests fixed:

  • test_team_token_output
  • test_allowed_routes_admin
  • test_allow_access_by_email
  • test_end_user_jwt_auth

All four tests call user_api_key_auth and enable JWT auth, making them subject to the enterprise check. The remaining seven tests in the file don't call user_api_key_auth and therefore don't need this fix.

Confidence Score: 5/5

  • This PR is safe to merge - it's a minimal, well-targeted test fix
  • The changes are test-only, follow an established pattern from PR fix(test): mock enterprise license check in JWT test #21285, target exactly the right tests (verified that all 4 tests call user_api_key_auth and enable JWT auth), and use consistent placement. The fix is minimal and addresses the root cause of test failures without modifying any production code.
  • No files require special attention

Important Files Changed

Filename Overview
tests/proxy_unit_tests/test_jwt.py Added premium_user=True to four JWT tests to bypass enterprise license check, enabling proper JWT functionality testing

Last reviewed commit: cde51a5

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jquinter jquinter merged commit 6b681aa into main Feb 20, 2026
19 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant