Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RHSSO identity by default #37

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions testsuite/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class Authorization(LifecycleObject):
def add_oidc_identity(self, name, endpoint):
"""Adds OIDC identity provider"""

@abc.abstractmethod
def add_api_key_identity(self, name, label):
"""Adds API Key identity"""

@abc.abstractmethod
def remove_all_identities(self):
"""Removes all identities from AuthConfig"""

@abc.abstractmethod
def add_host(self, hostname):
"""Adds host"""
Expand Down
6 changes: 6 additions & 0 deletions testsuite/openshift/objects/auth_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ def add_api_key_identity(self, name, label):
"keySelector": "APIKEY"
}
})

@modify
def remove_all_identities(self):
"""Removes all identities from AuthConfig"""
identities = self.model.spec.setdefault("identity", [])
identities.clear()
16 changes: 12 additions & 4 deletions testsuite/tests/kuadrant/authorino/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions testsuite/tests/kuadrant/authorino/identity/conftest.py
Original file line number Diff line number Diff line change
@@ -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