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

Enable multiple_host test on Kuadrant #160

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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
27 changes: 24 additions & 3 deletions testsuite/openshift/objects/auth_config/auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@

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


class AuthPolicy(AuthConfig):
"""AuthPolicy object, it serves as Kuadrants AuthConfig"""

def __init__(self, dict_to_model=None, string_to_model=None, context=None, route: HTTPRoute = None):
super().__init__(dict_to_model, string_to_model, context)
self._route = route

@property
def route(self) -> HTTPRoute:
"""Returns route to which the Policy is bound, won't work with objects fetched from Openshift"""
if not self._route:
# TODO: Fetch route from Openshift directly
raise ValueError("This instance doesnt have a Route specified!!")
return self._route

@property
def auth_section(self):
return self.model.spec.setdefault("authScheme", {})
Expand All @@ -19,7 +31,7 @@ def create_instance( # type: ignore
cls,
openshift: OpenShiftClient,
name,
route: Referencable,
route: HTTPRoute,
labels: Dict[str, str] = None,
hostnames: List[str] = None,
):
Expand All @@ -39,4 +51,13 @@ def create_instance( # type: ignore
if labels is not None:
model["metadata"]["labels"] = labels

return cls(model, context=openshift.context)
return cls(model, context=openshift.context, route=route)

def add_host(self, hostname):
return self.route.add_hostname(hostname)

def remove_host(self, hostname):
return self.route.remove_hostname(hostname)

def remove_all_hosts(self):
return self.route.remove_all_hostnames()
13 changes: 12 additions & 1 deletion testsuite/openshift/objects/gateway_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ def reference(self):
@modify
def add_hostname(self, hostname):
"""Adds hostname to the Route"""
self.model.spec.hostnames.append(hostname)
if hostname not in self.model.spec.hostnames:
self.model.spec.hostnames.append(hostname)

@modify
def remove_hostname(self, hostname):
"""Adds hostname to the Route"""
self.model.spec.hostnames.remove(hostname)

@modify
def remove_all_hostnames(self):
"""Adds hostname to the Route"""
self.model.spec.hostnames = []


# pylint: disable=too-many-instance-attributes
Expand Down
6 changes: 0 additions & 6 deletions testsuite/tests/kuadrant/authorino/multiple_hosts/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
from testsuite.httpx import HttpxBackoffClient


@pytest.fixture(scope="module")
def run_on_kuadrant():
"""Handling of hosts needs to be rewritten"""
return False


@pytest.fixture(scope="module")
def hostname(envoy):
"""Original hostname"""
Expand Down