litellm/tests
Ron Zhong 73fd5a41e4
feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948)
* feat: Singapore PDPA PII protection guardrail policy template

Add Singapore Personal Data Protection Act (PDPA) guardrail support:

Regex patterns (patterns.json):
- sg_nric: NRIC/FIN detection ([STFGM] + 7 digits + checksum letter)
- sg_phone: Singapore phone numbers (+65/0065/65 prefix)
- sg_postal_code: 6-digit postal codes (contextual)
- passport_singapore: Passport numbers (E/K + 7 digits, contextual)
- sg_uen: Unique Entity Numbers (3 formats)
- sg_bank_account: Bank account numbers (dash format, contextual)

YAML policy templates (5 sub-guardrails):
- sg_pdpa_personal_identifiers: s.13 Consent
- sg_pdpa_sensitive_data: Advisory Guidelines
- sg_pdpa_do_not_call: Part IX DNC Registry
- sg_pdpa_data_transfer: s.26 overseas transfers
- sg_pdpa_profiling_automated_decisions: Model AI Governance Framework

Policy template entry in policy_templates.json with 9 guardrail definitions
(4 regex-based + 5 YAML conditional keyword matching).

Tests:
- test_sg_patterns.py: regex pattern unit tests
- test_sg_pdpa_guardrails.py: conditional keyword matching tests (100+ cases)

* feat: MAS AI Risk Management Guidelines guardrail policy template

Add Monetary Authority of Singapore (MAS) AI Risk Management Guidelines
guardrail support for financial institutions:

YAML policy templates (5 sub-guardrails):
- sg_mas_fairness_bias: Blocks discriminatory financial AI (credit/loans/insurance by protected attributes)
- sg_mas_transparency_explainability: Blocks opaque/unexplainable AI for consequential financial decisions
- sg_mas_human_oversight: Blocks fully automated financial decisions without human-in-the-loop
- sg_mas_data_governance: Blocks unauthorized sharing/mishandling of financial customer data
- sg_mas_model_security: Blocks adversarial attacks, model poisoning, inversion on financial AI

Policy template entry in policy_templates.json with 5 guardrail definitions.
Aligned with MAS FEAT Principles, Project MindForge, and NIST AI RMF.

Tests:
- test_sg_mas_ai_guardrails.py: conditional keyword matching tests (100+ cases)

* fix: address SG pattern review feedback

- Update NRIC lowercase test for IGNORECASE runtime behavior
- Add keyword context guard to sg_uen pattern to reduce false positives

* docs: clarify MAS AIRM timeline references

- Explicitly mark MAS AIRM as Nov 2025 consultation draft
- Add 2018 qualifier for FEAT principles in MAS policy descriptions
- Update MAS guardrail wording to avoid release-year ambiguity

* chore: commit resolved MAS policy conflicts

* test:

* chore:
2026-02-23 12:08:22 -08:00
..
agent_tests
audio_tests
basic_proxy_startup_tests
batches_tests fix(tests): fix flaky test_create_vertex_fine_tune_jobs_mocked - handle background Datadog flush (#21838) 2026-02-21 14:44:01 -08:00
code_coverage_tests fix(ci): resolve mypy and check_code_and_doc_quality CI failures (#21812) 2026-02-21 13:08:47 -08:00
documentation_tests fix failing tests 2026-02-21 15:48:26 -08:00
enterprise fix: prevent double-counting of litellm_proxy_total_requests_metric (#21159) 2026-02-16 09:10:49 -08:00
guardrails_tests feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948) 2026-02-23 12:08:22 -08:00
image_gen_tests
litellm Revert "fix(proxy): recover from prisma-query-engine zombie process (#21707)" 2026-02-21 14:20:06 -08:00
litellm_core_utils
litellm_utils_tests Merge origin/main into perf/callback-registration-routing 2026-02-21 12:40:23 -08:00
litellm-proxy-extras
llm_responses_api_testing Fix anthropic responses 2026-02-20 17:30:42 -08:00
llm_translation Merge pull request #21701 from ta-stripe/fix/bedrock-openai-imported-model-name-encoding 2026-02-23 13:25:02 +05:30
load_tests
local_testing Revert "fix(vertex_ai): enable context-1m-2025-08-07 beta header (#21870)" (#21876) 2026-02-21 20:12:01 -08:00
logging_callback_tests Merge origin/main into litellm_perf_skip_usage_roundtrip 2026-02-21 12:55:55 -08:00
mcp_tests fix(tests): add spec_path=None to MCP server mocks to fix Pydantic validation 2026-02-20 13:13:48 -03:00
multi_instance_e2e_tests
ocr_tests
old_proxy_tests/tests
openai_endpoints_tests
otel_tests
pass_through_tests FIx: replace deprecated claude-3-7-sonnet-20250219 with claude-4-sonnet-20250514 2026-02-20 17:27:59 -08:00
pass_through_unit_tests Fix passthrough tests 2026-02-20 17:28:06 -08:00
proxy_admin_ui_tests fix(tests): skip remaining real prisma DB tests in CI and related test suites 2026-02-20 13:25:42 -03:00
proxy_e2e_anthropic_messages_tests Fix: litellm/tests/llm_responses_api_testing/test_anthropic_responses_api.py 2026-02-20 17:30:53 -08:00
proxy_security_tests
proxy_unit_tests Merge pull request #21786 from BerriAI/litellm_oss_staging_02_21_2026 2026-02-23 18:51:55 +05:30
router_unit_tests Merge pull request #20593 from ryan-crabbe/perf/reuse-litellm-params 2026-02-21 12:11:02 -08:00
scim_tests
search_tests Add duckcukgo in model map 2026-02-18 16:13:20 +05:30
spend_tracking_tests
store_model_in_db_tests
test_litellm feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948) 2026-02-23 12:08:22 -08:00
unified_google_tests
vector_store_tests
windows_tests
__init__.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
README.MD
test_budget_management.py
test_callbacks_on_proxy.py
test_config.py
test_debug_warning.py
test_default_encoding_non_root.py
test_end_users.py
test_entrypoint.py
test_fallbacks.py
test_gpt5_azure_temperature_support.py
test_health.py
test_keys.py
test_litellm_proxy_responses_config.py
test_logging.conf
test_models.py
test_openai_endpoints.py
test_organizations.py
test_otel_thread_leak.py
test_passthrough_endpoints.py
test_presidio_latency.py
test_proxy_server_non_root.py
test_ratelimit.py
test_resource_cleanup.py
test_service_logger_otel.py
test_spend_logs.py
test_team_logging.py
test_team_members.py
test_team.py fix(test): skip 'projects' field in team update assertion (#21777) 2026-02-21 10:24:53 -08:00
test_users.py fix(tests): update deprecated Anthropic model in test_user_model_access (#21826) 2026-02-21 14:18:24 -08:00

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/test_litellm

This folder can only run mock tests.