Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pattern-matching for AuthPolicy #582

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions testsuite/kuadrant/policy/authorization/auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from testsuite.utils import asdict
from .auth_config import AuthConfig
from .. import Policy
from . import Pattern

if TYPE_CHECKING:
from . import Rule
Expand Down Expand Up @@ -66,3 +67,10 @@ def overrides(self):
"""Add new rule into the `overrides` AuthPolicy section"""
self.spec_section = self.model.spec.setdefault("overrides", {})
return self

@modify
def add_patterns(self, patterns: dict[str, list[Pattern]]):
"""Add named pattern-matching expressions to be referenced in other "when" rules."""
self.model.spec.setdefault("patterns", {})
for key, value in patterns.items():
self.model.spec["patterns"].update({key: {"allOf": [asdict(x) for x in value]}})
Loading