Skip to content

Commit

Permalink
Reformat skipping of AuthPolicy using 'when'
Browse files Browse the repository at this point in the history
  • Loading branch information
azgabur committed Oct 30, 2023
1 parent 1f9adad commit 95ac311
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testsuite/openshift/objects/auth_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import cached_property
from typing import Dict, List, Optional

from testsuite.objects import Rule
from testsuite.objects import Rule, asdict
from testsuite.openshift.client import OpenShiftClient
from testsuite.openshift.objects import OpenShiftObject, modify
from .sections import IdentitySection, MetadataSection, ResponseSection, AuthorizationSection
Expand Down Expand Up @@ -75,4 +75,4 @@ def remove_all_hosts(self):
def add_rule(self, when: list[Rule]):
"""Add rule for the skip of entire AuthConfig"""
self.auth_section.setdefault("when", [])
self.auth_section["when"].extend([vars(x) for x in when])
self.auth_section["when"].extend([asdict(x) for x in when])
9 changes: 9 additions & 0 deletions testsuite/openshift/objects/auth_config/auth_policy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Module containing classes related to Auth Policy"""
from typing import Dict, List

from testsuite.objects import Rule, asdict

from testsuite.openshift.client import OpenShiftClient
from testsuite.openshift.objects import modify
from testsuite.openshift.objects.auth_config import AuthConfig
from testsuite.openshift.objects.gateway_api.route import HTTPRoute

Expand Down Expand Up @@ -55,3 +58,9 @@ def remove_host(self, hostname):

def remove_all_hosts(self):
return self.route.remove_all_hostnames()

@modify
def add_rule(self, when: list[Rule]):
"""Add rule for the skip of entire AuthPolicy"""
self.model.spec.setdefault("when", [])
self.model.spec["when"].extend([asdict(x) for x in when])

0 comments on commit 95ac311

Please sign in to comment.