Skip to content

Commit

Permalink
Update pattern-matching for AuthPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Smolar <[email protected]>
  • Loading branch information
jsmolar committed Nov 11, 2024
1 parent e93b295 commit 69b5c03
Showing 1 changed file with 8 additions and 0 deletions.
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]}})

0 comments on commit 69b5c03

Please sign in to comment.