Skip to content

Commit

Permalink
Merge pull request #37 from pehala/rhsso_default
Browse files Browse the repository at this point in the history
Use RHSSO identity by default
  • Loading branch information
pehala authored Aug 9, 2022
2 parents d82b701 + 696707d commit 2026521
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 4 deletions.
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

0 comments on commit 2026521

Please sign in to comment.