diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index c141f189..2c0c1ee5 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -1,4 +1,6 @@ """Root conftest""" +from urllib.parse import urlparse + import pytest from keycloak import KeycloakAuthenticationError @@ -125,3 +127,12 @@ def envoy(request, authorino, openshift, blame, backend, module_label): request.addfinalizer(envoy.delete) envoy.commit() return envoy + + +@pytest.fixture(scope="session") +def wildcard_domain(openshift): + """ + Wildcard domain of openshift cluster + """ + hostname = urlparse(openshift.api_url).hostname + return "*.apps." + hostname.split(".", 1)[1] diff --git a/testsuite/tests/kuadrant/authorino/conftest.py b/testsuite/tests/kuadrant/authorino/conftest.py index c8830abc..ce98303a 100644 --- a/testsuite/tests/kuadrant/authorino/conftest.py +++ b/testsuite/tests/kuadrant/authorino/conftest.py @@ -11,18 +11,29 @@ @pytest.fixture(scope="module") -def authorino(authorino, openshift, blame, request, testconfig, module_label) -> Authorino: +def authorino_parameters(): + """Optional parameters for Authorino creation, passed to the __init__""" + return {} + + +@pytest.fixture(scope="module") +def authorino(authorino, openshift, blame, request, testconfig, module_label, authorino_parameters) -> Authorino: """Authorino instance""" if authorino: return authorino if not testconfig["authorino"]["deploy"]: + if len(authorino_parameters) > 0: + return pytest.skip("Can't change parameters of already deployed Authorino") return PreexistingAuthorino(testconfig["authorino"]["url"]) + labels = authorino_parameters.setdefault("label_selectors", []) + labels.append(f"testRun={module_label}") + authorino = AuthorinoCR.create_instance(openshift, blame("authorino"), image=weakget(testconfig)["authorino"]["image"] % None, - label_selectors=[f"testRun={module_label}"]) + **authorino_parameters) request.addfinalizer(lambda: authorino.delete(ignore_not_found=True)) authorino.commit() authorino.wait_for_ready() diff --git a/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py b/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py index dfc1e30c..c4fbaaaa 100644 --- a/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/clusterwide/conftest.py @@ -5,9 +5,9 @@ @pytest.fixture(scope="module") -def cluster_wide(): +def authorino_parameters(): """Deploy Authorino in ClusterWide mode""" - return True + return {"cluster_wide": True} @pytest.fixture(scope="module") diff --git a/testsuite/tests/kuadrant/authorino/operator/conftest.py b/testsuite/tests/kuadrant/authorino/operator/conftest.py deleted file mode 100644 index 3b9adb52..00000000 --- a/testsuite/tests/kuadrant/authorino/operator/conftest.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Conftest for all tests requiring custom deployment of Authorino""" -from urllib.parse import urlparse - -import pytest -from weakget import weakget - -from testsuite.openshift.objects.authorino import AuthorinoCR - - -@pytest.fixture(scope="module") -def authorino_parameters(): - """Optional parameters for Authorino creation, passed to the __init__""" - return {} - - -@pytest.fixture(scope="module") -def cluster_wide(): - """True, if Authorino should be deployed in cluster-wide setup""" - return False - - -@pytest.fixture(scope="module") -def authorino(openshift, blame, request, testconfig, cluster_wide, module_label, authorino_parameters) -> AuthorinoCR: - """Custom deployed Authorino instance""" - if not testconfig["authorino"]["deploy"]: - return pytest.skip("Operator tests don't work with already deployed Authorino") - - if authorino_parameters.get("label_selectors"): - authorino_parameters["label_selectors"].append(f"testRun={module_label}") - else: - authorino_parameters["label_selectors"] = [f"testRun={module_label}"] - - authorino = AuthorinoCR.create_instance(openshift, - blame("authorino"), - cluster_wide=cluster_wide, - image=weakget(testconfig)["authorino"]["image"] % None, - **authorino_parameters) - request.addfinalizer(lambda: authorino.delete(ignore_not_found=True)) - authorino.commit() - authorino.wait_for_ready() - return authorino - - -@pytest.fixture(scope="session") -def wildcard_domain(openshift): - """ - Wildcard domain of openshift cluster - """ - hostname = urlparse(openshift.api_url).hostname - return "*.apps." + hostname.split(".", 1)[1]