litellm/tests/unit/proxy/hooks
tavren27 da8c02b9d5
fix(proxy): resolve a team wildcard deployment for a wildcard key on files, batches and RAG routes (#49744)
* fix(proxy): resolve a team wildcard deployment for a wildcard key on files, batches and RAG routes

A key allowed gpt-* in a team whose BYOK deployment is named openai/* fell back to the
environment OPENAI_API_KEY on /v1/files, /v1/batches and /v1/rag, because the key allowlist
check never matched a wildcard against a wildcard. Two wildcards now cover each other when
some model litellm knows for the deployment's provider matches both, so a claude-* key still
never resolves a team openai/* deployment

* test(proxy): type the team wildcard credentials helper's return

* fix(proxy): keep a restricted key on the team wildcard for RAG files and vector store file lists

Every files, RAG and vector store site now authorizes the model the key
reaches the team deployment by. A RAG upload is registered under that
model, so a later retrieve or delete by the same key passes auth, and the
vector store file list skips a team OpenAI model the key cannot call
instead of answering 403 on it

Put auth_checks back as it is on main, dropping the wildcard_pattern_regex
helper that CodeQL flagged

* fix(proxy): check every allowlist before a restricted key gets a team deployment's key

Files and batches give a key with its own allowlist the team deployment's provider key only once the model it reaches passes the key, team, org, and project checks that request auth runs

The vector store file list and the stored deployment check use the same gate for team deployments and keep main's exact-name check for proxy-wide ones, a RAG managed id never records a pattern from the key's own list, and the reverse match is computed once per call

* fix(proxy): try every model a restricted key reaches before picking a team provider key

Files, batches, RAG and vector store files now try each model the key and the team
deployment both cover and use the first one that passes the full key, team, org and
project checks, so a team narrower than the key, or a key whose first exact name the
team blocks, keeps the team's provider key. A deployment the key names directly wins
over one only two wildcards share, so adding a team openai/* model never moves a key
off the exact model it used before. The batch rate limiter and RAG ingest and query
use the same checked lookup as uploads, so the JSONL model check never reads a file
with a key the caller could not use

* fix(proxy): try the key's project allowlist names when resolving a team provider deployment

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-18 10:55:44 +00:00
..
litellm_skills ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
model_capacity_golden feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
__init__.py
native_capacity_handler.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
parallel_request_limiter_v3_golden.json feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_async_post_call_streaming_iterator_hook.py fix(guardrails): run the end-of-stream post_call scan when the client disconnects mid-stream (#43839) 2026-10-05 01:44:43 -07:00
test_autorouter_baseline_cache.py feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
test_banned_keyword_list.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_batch_enqueued_tokens.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_batch_enqueued_tokens_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_batch_file_validation.py fix(proxy): resolve a team wildcard deployment for a wildcard key on files, batches and RAG routes (#49744) 2026-11-18 10:55:44 +00:00
test_batch_rate_limiter.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_dynamic_rate_limiter.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_dynamic_rate_limiter_v3_on_native_limiter_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_dynamic_rate_limiter_v3_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_image_generation_guardrails.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_key_management_event_hooks.py feat(control_plane): dataplane registry, credential strategies and client (#49655) 2026-11-16 17:36:23 +00:00
test_max_budget_per_session_limiter.py fix(redis): share one native circuit breaker between RedisCache and the Rust stores (#50473) 2026-11-07 17:50:06 +09:00
test_max_iterations_limiter.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_message_thread_ownership.py feat(anthropic): forward message threads on native /v1/messages (#50976) 2026-11-10 18:33:54 -08:00
test_model_budget_shared_windows.py feat(proxy)!: model family and access group entries in model_max_budget (#47722) 2026-10-28 15:40:57 -07:00
test_model_capacity_native.golden.json feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_model_capacity_native.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_model_max_budget_limiter.py fix(proxy): model_max_budget entry on a model group covers its global aliases (#52385) 2026-11-17 16:42:52 -08:00
test_parallel_request_limiter.py fix(proxy): count native Responses WebSocket turn tokens toward key and tag TPM limits (#49257) 2026-10-31 02:53:27 -07:00
test_parallel_request_limiter_v3.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_parallel_request_limiter_v3_native.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_parallel_request_limiter_v3_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_post_call_failure_hook_integration.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_post_call_response_headers_hook.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_post_call_streaming_hook_integration.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_post_call_success_hook_integration.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_priority_class_share.py feat(dynamic_rate_limiter): customer organizations and keys borrow idle model capacity and split class shares (#51705) 2026-11-15 12:05:58 -08:00
test_prompt_cache_observer.py fix(proxy): keep a retried /v1/messages stream's spend log by logging the superseded attempt as a failure (#45136) 2026-10-16 21:19:58 +00:00
test_prompt_injection_detection.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_proxy_hooks_init.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_proxy_rate_limit_provider_field.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_proxy_rate_limit_provider_field_capacity_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_proxy_rate_limit_provider_field_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_proxy_track_cost_callback.py fix(responses): write one failure row per Responses WebSocket turn the deployment refuses (#50731) 2026-11-16 22:08:06 -08:00
test_rate_limiter_toctou_capacity_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_rate_limiter_toctou_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_search_free_tier.py fix(proxy): scope the search free-tier counter to the request's provider (#47646) 2026-10-20 22:01:53 +00:00
test_send_invite_email.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_sensitive_data_routing.py fix(redis): share one native circuit breaker between RedisCache and the Rust stores (#50473) 2026-11-07 17:50:06 +09:00
test_tpm_concurrent.py fix(proxy): leave cache-read tokens out of the priority limiter's token count (#52209) 2026-11-17 11:32:25 -08:00
test_tpm_concurrent_rust.py fix(google_genai): honor snake_case generation_config on generateContent (#51139) 2026-11-18 03:47:08 +00:00
test_unit_test_max_model_budget_limiter.py fix(router): inspect image content without translating routed requests (#49371) 2026-10-31 10:44:24 -07:00
test_user_management_event_hooks.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00