mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-14 04:09:09 +00:00
test(policy): reject empty config attachments
This commit is contained in:
parent
4b735f586a
commit
4e13146d4d
1 changed files with 8 additions and 16 deletions
|
|
@ -362,23 +362,15 @@ class TestMatchAttribution:
|
|||
)
|
||||
assert registry.get_attached_policies(context_no_tag) == []
|
||||
|
||||
def test_attachment_with_no_scope_matches_everything(self):
|
||||
"""Test that an attachment with no scope/teams/keys/models/tags
|
||||
matches everything because teams/keys/models default to ['*']."""
|
||||
def test_attachment_with_no_scope_is_rejected(self):
|
||||
"""Test that empty config attachments must use explicit global scope."""
|
||||
registry = AttachmentRegistry()
|
||||
registry.load_attachments(
|
||||
[
|
||||
{"policy": "catch-all"},
|
||||
]
|
||||
)
|
||||
|
||||
context = PolicyMatchContext(
|
||||
team_alias="any-team",
|
||||
key_alias="any-key",
|
||||
model="gpt-4",
|
||||
)
|
||||
attached = registry.get_attached_policies(context)
|
||||
assert "catch-all" in attached
|
||||
with pytest.raises(ValueError, match="at least one non-empty selector"):
|
||||
registry.load_attachments(
|
||||
[
|
||||
{"policy": "catch-all"},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class TestAttachmentRegistrySingleton:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue