Files
litellm/tests/test_litellm
371cabfebd Add MCP Security guardrail to block unregistered MCP servers (#21429)
* Add MCP_SECURITY enum to SupportedGuardrailIntegrations

* Add MCP security guardrail initializer

* Add MCPSecurityGuardrail implementation

* Add MCP Security policy template

* Add Type filter to policy templates UI

* Add unit tests for MCP security guardrail

* fix(lint): remove unused Dict import from mcp_security_guardrail

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

* Add French language support for EU AI Act Article 5 guardrail (#21427)

* Add French language support for EU AI Act Article 5 template

- Create eu_ai_act_article5_fr.yaml with comprehensive French keywords
- Includes identifier words: concevoir, créer, développer, noter, classer, etc.
- Includes block words: crédit social, comportement social, émotion des employés, etc.
- Includes always-block keywords for explicit prohibited practices
- Includes exceptions for research, compliance, and legitimate use cases
- Catches circumvention attempts with phrase variations

* Add comprehensive tests for French EU AI Act guardrail

- Test 3 critical scenarios: blocked query, circumvention attempt, safe query
- Test edge cases: case-insensitive, mixed language, research exceptions
- All 7 tests passing
- Validates both blocking and allowing behavior

* Fix content filter to support conditional matching without inherit_from

- Enable conditional matching when identifier_words + additional_block_words are present
- Previously required inherit_from, but EU AI Act templates are self-contained
- Fixes Greptile feedback: conditional matching now works as documented

* Add pure conditional matching test for French guardrail

- Test identifier + block word combinations not in always_block_keywords
- Verifies conditional matching works independently
- Addresses Greptile feedback about test coverage gap

* Fix exception word bypass risk in French template

- Replace short words (film, jeu, juste) with context-specific phrases
- Prevents substring matching bypasses (e.g., enjeu matching jeu)
- Add tests for bypass prevention and legitimate game context
- Addresses Greptile security feedback

* Make conditional match assertion more robust

- Use getattr to safely access exception detail field
- Check if detail is dict before calling .get()
- Addresses Greptile feedback about brittle string assertion

* Add French EU AI Act Article 5 policy template to registry

- Add eu-ai-act-article5-fr template for French language support
- Includes French description and guardrail info
- Matches structure of English template

* Address greptile review feedback (greploop iteration 1)

- Use status_code=400 instead of 403 to match guardrail logging convention
- Use prefix stripping instead of split('/')[-1] for robust server name extraction

* remove French EU AI Act template from policy_templates.json

---------

Co-authored-by: Julio Quinteros Pro <jquinter@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 21:19:13 -08:00
..
2026-02-16 20:13:55 -08:00
2026-01-24 11:13:44 -08:00
2026-02-14 13:40:48 -08:00

Testing for litellm/

This directory 1:1 maps the the litellm/ directory, and can only contain mocked tests.

The point of this is to:

  1. Increase test coverage of litellm/
  2. Make it easy for contributors to add tests for the litellm/ package and easily run tests without needing LLM API keys.

File name conventions

  • litellm/proxy/test_caching_routes.py maps to litellm/proxy/caching_routes.py
  • test_<filename>.py maps to litellm/<filename>.py