diff --git a/testsuite/policy/authorization/auth_policy.py b/testsuite/policy/authorization/auth_policy.py index 33cf7a7e..a5e2adb7 100644 --- a/testsuite/policy/authorization/auth_policy.py +++ b/testsuite/policy/authorization/auth_policy.py @@ -35,7 +35,6 @@ def create_instance( "metadata": {"name": name, "namespace": openshift.project, "labels": labels}, "spec": { "targetRef": target.reference, - "rules": {}, }, } diff --git a/testsuite/policy/authorization/sections.py b/testsuite/policy/authorization/sections.py index 442a0cab..9b42f157 100644 --- a/testsuite/policy/authorization/sections.py +++ b/testsuite/policy/authorization/sections.py @@ -67,10 +67,18 @@ def section(self): """The actual dict section which will be edited""" return self.obj.auth_section.setdefault(self.section_name, {}) - def add_item(self, name: str, value: dict, **common_features): + def add_item(self, name: str, value: dict, *, defaults: bool = False, overrides: bool = False, **common_features): """Adds item to the section""" add_common_features(value, **common_features) - self.section.update({name: value}) + + if defaults: + section = self.obj.model.spec.setdefault("defaults", {}).setdefault("rules", {}) + elif overrides: + section = self.obj.model.spec.setdefault("overrides", {}).setdefault("rules", {}) + else: + section = self.obj.auth_section + + section.setdefault(self.section_name, {}).update({name: value}) @modify def clear_all(self): diff --git a/testsuite/policy/rate_limit_policy.py b/testsuite/policy/rate_limit_policy.py index 37abaa47..6c63a7cf 100644 --- a/testsuite/policy/rate_limit_policy.py +++ b/testsuite/policy/rate_limit_policy.py @@ -52,7 +52,6 @@ def create_instance(cls, openshift: OpenShiftClient, name, target: Referencable, "metadata": {"name": name, "labels": labels}, "spec": { "targetRef": target.reference, - "limits": {}, }, } @@ -66,6 +65,8 @@ def add_limit( when: Iterable[Rule] = None, counters: list[str] = None, route_selectors: Iterable[RouteSelector] = None, + defaults: bool = False, + overrides: bool = False, ): """Add another limit""" limit: dict = { @@ -77,7 +78,15 @@ def add_limit( limit["counters"] = counters if route_selectors: limit["routeSelectors"] = [asdict(rule) for rule in route_selectors] - self.model.spec.limits[name] = limit + + if defaults: + section = self.model.spec.setdefault("defaults", {}) + elif overrides: + section = self.model.spec.setdefault("overrides", {}) + else: + section = self.model.spec + + section.setdefault("limits", {})[name] = limit def wait_for_ready(self): """Wait for RLP to be enforced"""