Skip to content

Commit

Permalink
add port parameter to openshift.types.routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkudlej committed Sep 8, 2022
1 parent 60c0cf5 commit c562178
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion testsuite/openshift/types/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 3 additions & 4 deletions testsuite/tests/kuadrant/authorino/operator/http/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ''

0 comments on commit c562178

Please sign in to comment.