Skip to content

Commit

Permalink
Use modul label for AuthConfig when sharding is tested
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Smolar <[email protected]>
  • Loading branch information
jsmolar committed Sep 10, 2024
1 parent b831e9f commit 76c35e1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,15 +47,34 @@ 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):
auth = AuthConfig.create_instance(
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 76c35e1

Please sign in to comment.