From 519095bfe5b5f5911a1ee123f22ebdfdd1d25ca5 Mon Sep 17 00:00:00 2001 From: shreyes19 Date: Sat, 11 Apr 2026 21:13:04 +0530 Subject: [PATCH] test: add structural proxy_server CORS invariant test (Greptile review feedback) Add test_proxy_server_cors_invariant which directly imports and checks the module-level origins and allow_cors_credentials variables in proxy_server.py. This catches any future drift between the mirror helper and the real code. --- tests/test_litellm/proxy/test_cors_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_litellm/proxy/test_cors_config.py b/tests/test_litellm/proxy/test_cors_config.py index de7c62422a9..4af939e903d 100644 --- a/tests/test_litellm/proxy/test_cors_config.py +++ b/tests/test_litellm/proxy/test_cors_config.py @@ -77,3 +77,15 @@ def test_cors_origins_skips_blank_entries(): origins, allow_credentials = _compute_cors_config("https://a.com,,https://b.com,") assert origins == ["https://a.com", "https://b.com"] assert allow_credentials is True + + +def test_proxy_server_cors_invariant(): + """should verify that proxy_server.allow_cors_credentials is always consistent + with proxy_server.origins — catches any future drift between the two variables.""" + import litellm.proxy.proxy_server as proxy_server + + assert proxy_server.allow_cors_credentials == ("*" not in proxy_server.origins), ( + f"Invariant broken: allow_cors_credentials={proxy_server.allow_cors_credentials} " + f"but origins={proxy_server.origins}. " + "When origins contains '*', allow_credentials must be False." + )