Skip to content

Commit

Permalink
Merge pull request Kuadrant#582 from jsmolar/jsmolar2
Browse files Browse the repository at this point in the history
Update pattern-matching for AuthPolicy
  • Loading branch information
averevki authored Nov 12, 2024
2 parents e93b295 + 69b5c03 commit 2dc33cc
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 2dc33cc

Please sign in to comment.