mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
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.
This commit is contained in:
parent
e079ee779f
commit
519095bfe5
1 changed files with 12 additions and 0 deletions
|
|
@ -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."
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue