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

Enable running on already deployed Authorino #12

Merged
merged 1 commit into from
Jul 4, 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
4 changes: 4 additions & 0 deletions config/settings.local.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
# test_user:
# username: "testUser"
# password: "testPassword"
# authorino:
# image: "quay.io/kuadrant/authorino:latest" # If specified will override the authorino image
# deploy: false # If false, the testsuite will use already deployed authorino for testing
# url: "" # URL for already deployed Authorino
4 changes: 3 additions & 1 deletion config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ default:
rhsso:
test_user:
username: "testUser"
password: "testPassword"
password: "testPassword"
authorino:
deploy: true
5 changes: 4 additions & 1 deletion testsuite/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Testsuite configuration"""
from dynaconf import Dynaconf
from dynaconf import Dynaconf, Validator

settings = Dynaconf(
environments=True,
Expand All @@ -8,4 +8,7 @@
settings_files=["config/settings.yaml", "config/secrets.yaml"],
envvar_prefix="KUADRANT",
merge_enabled=True,
validators=[
Validator("authorino.deploy", eq=True) | Validator("authorino.url", must_exist=True)
]
)
21 changes: 21 additions & 0 deletions testsuite/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ class Authorization(LifecycleObject):
@abc.abstractmethod
def add_oidc_identity(self, name, endpoint):
"""Adds OIDC identity provider"""


class PreexistingAuthorino(Authorino):
"""Authorino which is already deployed prior to the testrun"""

def __init__(self, authorization_url) -> None:
super().__init__()
self._authorization_url = authorization_url

def wait_for_ready(self):
return True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we don't care if the preexisting Authorino instance is NOT ready, right? Tests will fail of course, but that's all right. Any preexisting Authorino instance is supposed to be ready before using this option, I imagine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, and even if we wanted we cannot assume that we have permission to view the status of it, it might be located in a completely different namespace.


@property
def authorization_url(self):
return self._authorization_url

def commit(self):
return

def delete(self):
return
7 changes: 5 additions & 2 deletions testsuite/tests/kuadrant/authorino/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
import pytest

from testsuite.openshift.objects.auth_config import AuthConfig
from testsuite.objects import Authorino, Authorization
from testsuite.objects import Authorino, Authorization, PreexistingAuthorino
from testsuite.openshift.objects.authorino import AuthorinoCR


@pytest.fixture(scope="session")
def authorino(authorino, openshift, blame, request) -> Authorino:
def authorino(authorino, openshift, blame, request, testconfig) -> Authorino:
"""Authorino instance"""
if authorino:
return authorino

if not testconfig["authorino"]["deploy"]:
return PreexistingAuthorino(testconfig["authorino"]["url"])

authorino = AuthorinoCR.create_instance(openshift, blame("authorino"))
request.addfinalizer(lambda: authorino.delete(ignore_not_found=True))
authorino.commit()
Expand Down
5 changes: 4 additions & 1 deletion testsuite/tests/kuadrant/authorino/operator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@


@pytest.fixture(scope="session")
def authorino(openshift, blame, request) -> AuthorinoCR:
def authorino(openshift, blame, request, testconfig) -> AuthorinoCR:
"""Custom deployed Authorino instance"""
if not testconfig["authorino"]["deploy"]:
return pytest.skip("Operator tests don't work with already deployed Authorino")

authorino = AuthorinoCR.create_instance(openshift, blame("authorino"))
request.addfinalizer(lambda: authorino.delete(ignore_not_found=True))
authorino.commit()
Expand Down