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): use a generic route prefix in wildcard route tests
milan07416344cc88
diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.pyindex 9d8eedaa7dc..bf7a6a8f6c3 100644--- a/litellm/proxy/auth/auth_checks.py+++ b/litellm/proxy/auth/auth_checks.py@@ -1129,7 +1129,7 @@ def _allowed_routes_check(user_route: str, allowed_routes: list) -> bool:Parameters:- user_route: str - the route the user is trying to call- allowed_routes: List[str|LiteLLMRoutes] - the list of allowed routes for the user. Entries are a route group name- (e.g. "openai_routes"), an exact route, or a trailing-wildcard prefix (e.g. "/tempus/*").+ (e.g. "openai_routes"), an exact route, or a trailing-wildcard prefix (e.g. "/internal-models/*")."""from starlette.routing import compile_pathdiff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/test_litellm/proxy/auth/test_auth_checks.pyindex 0b174cda9d5..7fa16508054 100644--- a/tests/test_litellm/proxy/auth/test_auth_checks.py+++ b/tests/test_litellm/proxy/auth/test_auth_checks.py@@ -6901,9 +6901,9 @@ def test_model_has_no_cost_mapping_alias_to_a_group_priced_through_model_info_is@pytest.mark.parametrize("user_route, expected",[- ("/tempus/v1/chat/completions", True),- ("/tempus/newly-registered-model/predict", True),- ("/tempus-other/v1/chat/completions", False),+ ("/internal-models/v1/chat/completions", True),+ ("/internal-models/newly-registered-model/predict", True),+ ("/internal-models-other/v1/chat/completions", False),("/anthropic/v1/messages", False),],)@@ -6918,7 +6918,7 @@ def test_team_allowed_routes_wildcard_prefix_matches_unregistered_passthrough_roallowed_routes_check(user_role=LitellmUserRoles.TEAM,user_route=user_route,- litellm_proxy_roles=LiteLLM_JWTAuth(team_allowed_routes=["/tempus/*"]),+ litellm_proxy_roles=LiteLLM_JWTAuth(team_allowed_routes=["/internal-models/*"]),)is expected)@@ -6928,14 +6928,14 @@ def test_team_allowed_routes_exact_route_does_not_become_a_prefix_grant():from litellm.proxy._types import LiteLLM_JWTAuthfrom litellm.proxy.auth.auth_checks import allowed_routes_check- roles = LiteLLM_JWTAuth(team_allowed_routes=["/tempus/model-a"])+ roles = LiteLLM_JWTAuth(team_allowed_routes=["/internal-models/model-a"])assert (- allowed_routes_check(user_role=LitellmUserRoles.TEAM, user_route="/tempus/model-a", litellm_proxy_roles=roles)+ allowed_routes_check(user_role=LitellmUserRoles.TEAM, user_route="/internal-models/model-a", litellm_proxy_roles=roles)is True)assert (- allowed_routes_check(user_role=LitellmUserRoles.TEAM, user_route="/tempus/model-b", litellm_proxy_roles=roles)+ allowed_routes_check(user_role=LitellmUserRoles.TEAM, user_route="/internal-models/model-b", litellm_proxy_roles=roles)is False)@@ -6944,11 +6944,11 @@ def test_admin_allowed_routes_wildcard_prefix_is_honored():from litellm.proxy._types import LiteLLM_JWTAuthfrom litellm.proxy.auth.auth_checks import allowed_routes_check- roles = LiteLLM_JWTAuth(admin_allowed_routes=["/tempus/*"])+ roles = LiteLLM_JWTAuth(admin_allowed_routes=["/internal-models/*"])assert (allowed_routes_check(- user_role=LitellmUserRoles.PROXY_ADMIN, user_route="/tempus/anything", litellm_proxy_roles=roles+ user_role=LitellmUserRoles.PROXY_ADMIN, user_route="/internal-models/anything", litellm_proxy_roles=roles)is True)