diff --git a/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py b/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py index 5209e298..5d1c8817 100644 --- a/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py +++ b/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py @@ -1,7 +1,9 @@ """Conftest for authorino sharding tests""" import pytest +from weakget import weakget +from testsuite.kuadrant.authorino import AuthorinoCR from testsuite.kuadrant.policy.authorization import Value, JsonResponse from testsuite.gateway.envoy import Envoy from testsuite.kuadrant.policy.authorization.auth_config import AuthConfig @@ -45,7 +47,26 @@ def _route(hostname, gateway): @pytest.fixture(scope="module") -def setup_authorization(request, blame, cluster, label): # pylint: disable=unused-argument +def setup_authorino(cluster, blame, testconfig, module_label, request): + """Authorino instance""" + + def _authorino(sharding_label): + authorino = AuthorinoCR.create_instance( + cluster, + blame("authorino"), + image=weakget(testconfig)["authorino"]["image"] % None, + label_selectors=[f"sharding={sharding_label}", f"testRun={module_label}"], + ) + request.addfinalizer(authorino.delete) + authorino.commit() + authorino.wait_for_ready() + return authorino + + return _authorino + + +@pytest.fixture(scope="module") +def setup_authorization(request, blame, cluster, module_label): # pylint: disable=unused-argument """Factory method for creating AuthConfigs in the test run""" def _authorization(route, sharding_label=None): @@ -53,7 +74,7 @@ def _authorization(route, sharding_label=None): cluster, blame("ac"), route, - labels={"testRun": label, "sharding": sharding_label}, + labels={"testRun": module_label, "sharding": sharding_label}, ) auth.responses.add_success_header("header", JsonResponse({"anything": Value(sharding_label)})) request.addfinalizer(auth.delete) diff --git a/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py b/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py index 6ac28d47..3b72ef62 100644 --- a/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py +++ b/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py @@ -8,25 +8,6 @@ pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only] -@pytest.fixture(scope="module") -def setup_authorino(cluster, blame, testconfig, label, request): - """Authorino instance""" - - def _authorino(sharding_label): - authorino = AuthorinoCR.create_instance( - cluster, - blame("authorino"), - image=weakget(testconfig)["authorino"]["image"] % None, - label_selectors=[f"sharding={sharding_label}", f"testRun={label}"], - ) - request.addfinalizer(authorino.delete) - authorino.commit() - authorino.wait_for_ready() - return authorino - - return _authorino - - @pytest.mark.issue("https://github.com/Kuadrant/authorino/pull/349") def test_preexisting_auth( setup_authorino, setup_authorization, setup_gateway, setup_route, exposer, wildcard_domain, blame diff --git a/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py b/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py index 9bde949c..e46d1c93 100644 --- a/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py +++ b/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py @@ -6,10 +6,8 @@ @pytest.fixture(scope="module") -def authorino_parameters(authorino_parameters): - """Setup sharding for authorino""" - authorino_parameters["label_selectors"] = ["sharding=A"] - yield authorino_parameters +def authorino(setup_authorino): + return setup_authorino(sharding_label="A") def test_sharding(setup_authorization, setup_gateway, setup_route, authorino, exposer, blame):