diff --git a/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py b/testsuite/tests/singlecluster/authorino/operator/sharding/conftest.py index a843171c..368009de 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 @@ -46,7 +48,26 @@ def _route(hostname, gateway): @pytest.fixture(scope="module") -def setup_authorization(request, blame, cluster, module_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): """Factory method for creating AuthConfigs in the test run""" def _authorization(route, sharding_label=None): 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 027c20bc..a58515bc 100644 --- a/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py +++ b/testsuite/tests/singlecluster/authorino/operator/sharding/test_preexisting_auth.py @@ -1,32 +1,10 @@ """Test for preexisting authorino bug issue:https://github.com/Kuadrant/testsuite/issues/69""" import pytest -from weakget import weakget - -from testsuite.kuadrant.authorino import AuthorinoCR pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only] -@pytest.fixture(scope="module") -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.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..85819a8d 100644 --- a/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py +++ b/testsuite/tests/singlecluster/authorino/operator/sharding/test_sharding.py @@ -6,10 +6,9 @@ @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): + """Creates authorino with sharding label""" + return setup_authorino(sharding_label="A") def test_sharding(setup_authorization, setup_gateway, setup_route, authorino, exposer, blame):