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
Jakub Smolar committed Sep 10, 2024
1 parent e12cfad commit 1041a37
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 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 @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1041a37

Please sign in to comment.