From e74844274fc972db2c36a4cf7b91263504430527 Mon Sep 17 00:00:00 2001 From: phala Date: Thu, 4 Aug 2022 11:34:05 +0200 Subject: [PATCH] Reorganize testsuite - All directories are now setup to work with RHSSO - Identity is different as that is the only one which reverts it - Move Multiple_hosts out of RHSSO folder --- testsuite/tests/kuadrant/authorino/conftest.py | 16 ++++++++++++---- .../kuadrant/authorino/identity/conftest.py | 9 +++++++++ .../rhsso => }/multiple_hosts/__init__.py | 0 .../rhsso => }/multiple_hosts/conftest.py | 0 .../multiple_hosts/test_multiple_hosts.py | 0 .../multiple_hosts/test_remove_host.py | 0 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 testsuite/tests/kuadrant/authorino/identity/conftest.py rename testsuite/tests/kuadrant/authorino/{identity/rhsso => }/multiple_hosts/__init__.py (100%) rename testsuite/tests/kuadrant/authorino/{identity/rhsso => }/multiple_hosts/conftest.py (100%) rename testsuite/tests/kuadrant/authorino/{identity/rhsso => }/multiple_hosts/test_multiple_hosts.py (100%) rename testsuite/tests/kuadrant/authorino/{identity/rhsso => }/multiple_hosts/test_remove_host.py (100%) diff --git a/testsuite/tests/kuadrant/authorino/conftest.py b/testsuite/tests/kuadrant/authorino/conftest.py index 988d82765..a68c3af34 100644 --- a/testsuite/tests/kuadrant/authorino/conftest.py +++ b/testsuite/tests/kuadrant/authorino/conftest.py @@ -2,6 +2,7 @@ import pytest from weakget import weakget +from testsuite.httpx.auth import HttpxOidcClientAuth from testsuite.openshift.objects.auth_config import AuthConfig from testsuite.objects import Authorino, Authorization, PreexistingAuthorino from testsuite.openshift.objects.authorino import AuthorinoCR @@ -28,12 +29,19 @@ def authorino(authorino, openshift, blame, request, testconfig, label) -> Author # pylint: disable=unused-argument @pytest.fixture(scope="module") -def authorization(authorization, authorino, envoy, blame, openshift, label) -> Authorization: +def authorization(authorization, authorino, envoy, blame, openshift, label, rhsso_service_info) -> Authorization: """In case of Authorino, AuthConfig used for authorization""" - if authorization: - return authorization + if authorization is None: + authorization = AuthConfig.create_instance(openshift, blame("ac"), envoy.hostname, labels={"testRun": label}) + authorization.add_oidc_identity("rhsso", rhsso_service_info.issuer_url()) + return authorization - return AuthConfig.create_instance(openshift, blame("ac"), envoy.hostname, labels={"testRun": label}) + +@pytest.fixture(scope="module") +def auth(rhsso_service_info): + """Returns RHSSO authentication object for HTTPX""" + return HttpxOidcClientAuth(rhsso_service_info.client, "authorization", + rhsso_service_info.username, rhsso_service_info.password) @pytest.fixture(scope="module") diff --git a/testsuite/tests/kuadrant/authorino/identity/conftest.py b/testsuite/tests/kuadrant/authorino/identity/conftest.py new file mode 100644 index 000000000..8c4840b7e --- /dev/null +++ b/testsuite/tests/kuadrant/authorino/identity/conftest.py @@ -0,0 +1,9 @@ +"""Conftest for all Identity tests""" +import pytest + + +@pytest.fixture(scope="module") +def authorization(authorization): + """For Identity tests remove all identities previously setup""" + authorization.remove_all_identities() + return authorization diff --git a/testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/__init__.py b/testsuite/tests/kuadrant/authorino/multiple_hosts/__init__.py similarity index 100% rename from testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/__init__.py rename to testsuite/tests/kuadrant/authorino/multiple_hosts/__init__.py diff --git a/testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/conftest.py b/testsuite/tests/kuadrant/authorino/multiple_hosts/conftest.py similarity index 100% rename from testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/conftest.py rename to testsuite/tests/kuadrant/authorino/multiple_hosts/conftest.py diff --git a/testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/test_multiple_hosts.py b/testsuite/tests/kuadrant/authorino/multiple_hosts/test_multiple_hosts.py similarity index 100% rename from testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/test_multiple_hosts.py rename to testsuite/tests/kuadrant/authorino/multiple_hosts/test_multiple_hosts.py diff --git a/testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/test_remove_host.py b/testsuite/tests/kuadrant/authorino/multiple_hosts/test_remove_host.py similarity index 100% rename from testsuite/tests/kuadrant/authorino/identity/rhsso/multiple_hosts/test_remove_host.py rename to testsuite/tests/kuadrant/authorino/multiple_hosts/test_remove_host.py