diff --git a/testsuite/openshift/types/routes.py b/testsuite/openshift/types/routes.py index 041c6e06..f3407791 100644 --- a/testsuite/openshift/types/routes.py +++ b/testsuite/openshift/types/routes.py @@ -8,12 +8,14 @@ class Routes(RemoteMapping): def __init__(self, client) -> None: super().__init__(client, "route") - def expose(self, name, service, hostname=None): + def expose(self, name, service, hostname=None, port=None): """Expose containers internally as services or externally via routes. Returns requested route in yaml format. """ extra_args = [] if hostname is not None: extra_args.append(f"--hostname={hostname}") + if port is not None: + extra_args.append(f"--port={port}") return self._client.do_action("expose", "service", f"--name={name}", "-o", "json", service, *extra_args, parse_output=True) diff --git a/testsuite/tests/kuadrant/authorino/operator/http/conftest.py b/testsuite/tests/kuadrant/authorino/operator/http/conftest.py index 4e34f092..e6fc1eb5 100644 --- a/testsuite/tests/kuadrant/authorino/operator/http/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/http/conftest.py @@ -7,7 +7,7 @@ # pylint: disable=unused-argument @pytest.fixture(scope="module") -def authorization(authorization, wildcard_domain, blame, openshift, rhsso_service_info, module_label) -> Authorization: +def authorization(authorization, wildcard_domain, openshift, rhsso_service_info, module_label) -> Authorization: """In case of Authorino, AuthConfig used for authorization""" authorization.remove_all_hosts() authorization.add_host(wildcard_domain) @@ -21,7 +21,7 @@ def authorization(authorization, wildcard_domain, blame, openshift, rhsso_servic @pytest.fixture(scope="module") -def client_http_auth(authorization, authorino_route): +def client(authorization, authorino_route): """Returns httpx client to be used for requests, it also commits AuthConfig""" client = HttpxBackoffClient(base_url=f"http://{authorino_route.model.spec.host}", verify=False) yield client @@ -31,8 +31,7 @@ def client_http_auth(authorization, authorino_route): @pytest.fixture(scope="module") def authorino_route(authorino, blame, openshift): """Add route for authorino http port to be able to access it.""" - name = f"route-{authorino.name()}" - route = openshift.routes.expose(name, f"{authorino.name()}-authorino-authorization", + route = openshift.routes.expose(blame('route'), f"{authorino.name()}-authorino-authorization", port='http') yield route route.delete() diff --git a/testsuite/tests/kuadrant/authorino/operator/http/test_raw_http.py b/testsuite/tests/kuadrant/authorino/operator/http/test_raw_http.py index ac199505..355eabbc 100644 --- a/testsuite/tests/kuadrant/authorino/operator/http/test_raw_http.py +++ b/testsuite/tests/kuadrant/authorino/operator/http/test_raw_http.py @@ -4,17 +4,17 @@ # pylint: disable=unused-argument -def test_authorized_via_http(authorization, client_http_auth, auth): +def test_authorized_via_http(authorization, client, auth): """Test raw http authentization with Keycloak.""" - response = client_http_auth.request("GET", "/check", auth=auth) + response = client.get("/check", auth=auth) assert response.status_code == 200 assert response.text == '' assert response.headers.get('x-ext-auth-other-json', '') == '{"propX":"valueX"}' # pylint: disable=unused-argument -def test_unauthorized_via_http(authorization, client_http_auth): +def test_unauthorized_via_http(authorization, client): """Test raw http authentization with unauthorized request.""" - response = client_http_auth.request("GET", "/check") + response = client.get("/check") assert response.status_code == 401 assert response.text == ''