litellm/tests/unit/test_router
mrinal-berri 0ab513bea0
feat(guardrails): reject requests that name an unregistered guardrail when reject_unregistered_guardrails is on (#53214)
* feat(guardrails): reject requests that name an unregistered guardrail when reject_unregistered_guardrails is on

A request whose merged guardrails (request body, key, team, project, policy and model level) name a guardrail that is not registered on the proxy is served today with no guardrail and no error. With general_settings.reject_unregistered_guardrails: true, pre_call_hook now returns 400 naming the unregistered guardrails, including when no guardrails are registered at all. Off by default; skip_guardrails callers are not checked.

Resolves LIT-4787

* fix(guardrails): read every requested guardrail shape and a string "true" setting in the unregistered-guardrail check

The check skipped a metadata.guardrails value that was not a clean list of names, so an unregistered name in a {name: true} toggle map, a bare string, or a list with a non-name entry was still served unguarded, while the runtime does run registered names from those shapes. It now reads names from all of them. reject_unregistered_guardrails is parsed as a boolean the way fail_closed_rate_limit_enforcement is, so "true" turns it on and a non-boolean value logs a warning instead of being dropped silently.

* fix(guardrails): validate legacy toggles, policy steps, and A2A guardrails

* fix(a2a): validate agent guardrails before reserving rate limits

* test(guardrails): use raw strings for regex assertions

* fix(guardrails): validate selected fallback deployments before dispatch

* fix(router): keep guardrail validation imports proxy-scoped
2026-11-20 18:39:29 -08:00
..
core feat(guardrails): reject requests that name an unregistered guardrail when reject_unregistered_guardrails is on (#53214) 2026-11-20 18:39:29 -08:00
__init__.py test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
test_enforce_model_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_io_token_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router.py feat(auth): read projects, tags, access groups and object permissions through rust repositories (#52178) 2026-11-18 22:32:06 +00:00
test_router_callback_hook_sequence.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_router_endpoints.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_entry_points.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_router_facade.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fallbacks.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fuzz_regressions_rust_only.py 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
test_router_get_deployments.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_helper_utils.py fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
test_router_host.py 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
test_router_max_parallel_requests.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_router_provider_endpoints.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_router_retries.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00