mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
ci: only run selenium for E2E tests when needed (#21217)
* ci: less selenium Signed-off-by: Jens Langhammer <jens@goauthentik.io> * oidc needs selenium Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
+5
-7
@@ -87,15 +87,13 @@ class DockerTestCase(TestCase):
|
||||
"""Output the container logs to our STDOUT"""
|
||||
if not container:
|
||||
return
|
||||
if IS_CI:
|
||||
image = container.image
|
||||
if image:
|
||||
tags = image.tags[0] if len(image.tags) > 0 else str(image)
|
||||
print(f"::group::Container logs - {tags}")
|
||||
image = container.image
|
||||
if image:
|
||||
tags = image.tags[0] if len(image.tags) > 0 else str(image)
|
||||
print(f"::group::Container logs - {tags}")
|
||||
for log in container.logs().decode().split("\n"):
|
||||
print(log)
|
||||
if IS_CI:
|
||||
print("::endgroup::")
|
||||
print("::endgroup::")
|
||||
|
||||
def tearDown(self) -> None:
|
||||
containers: list[Container] = self.docker_client.containers.list(
|
||||
|
||||
@@ -8,6 +8,8 @@ services:
|
||||
- "host.docker.internal:host-gateway"
|
||||
labels:
|
||||
- io.goauthentik.tests=selenium
|
||||
profiles:
|
||||
- selenium
|
||||
mailpit:
|
||||
image: docker.io/axllent/mailpit:v1.29.4
|
||||
ports:
|
||||
|
||||
@@ -14,10 +14,10 @@ from authentik.lib.generators import generate_id
|
||||
from authentik.outposts.apps import MANAGED_OUTPOST
|
||||
from authentik.outposts.models import Outpost, OutpostConfig, OutpostType
|
||||
from authentik.providers.ldap.models import APIAccessMode, LDAPProvider
|
||||
from tests.e2e.utils import SeleniumTestCase, retry
|
||||
from tests.e2e.utils import E2ETestCase, retry
|
||||
|
||||
|
||||
class TestProviderLDAP(SeleniumTestCase):
|
||||
class TestProviderLDAP(E2ETestCase):
|
||||
"""LDAP and Outpost e2e tests"""
|
||||
|
||||
def start_ldap(self, outpost: Outpost):
|
||||
|
||||
@@ -13,10 +13,10 @@ from authentik.flows.models import Flow
|
||||
from authentik.lib.generators import generate_id, generate_key
|
||||
from authentik.outposts.models import Outpost, OutpostConfig, OutpostType
|
||||
from authentik.providers.radius.models import RadiusProvider
|
||||
from tests.e2e.utils import SeleniumTestCase, retry
|
||||
from tests.e2e.utils import E2ETestCase, retry
|
||||
|
||||
|
||||
class TestProviderRadius(SeleniumTestCase):
|
||||
class TestProviderRadius(E2ETestCase):
|
||||
"""Radius Outpost e2e tests"""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -12,10 +12,10 @@ from authentik.sources.ldap.sync.groups import GroupLDAPSynchronizer
|
||||
from authentik.sources.ldap.sync.membership import MembershipLDAPSynchronizer
|
||||
from authentik.sources.ldap.sync.users import UserLDAPSynchronizer
|
||||
from authentik.tasks.models import Task
|
||||
from tests.e2e.utils import SeleniumTestCase, retry
|
||||
from tests.e2e.utils import E2ETestCase, retry
|
||||
|
||||
|
||||
class TestSourceLDAPSamba(SeleniumTestCase):
|
||||
class TestSourceLDAPSamba(E2ETestCase):
|
||||
"""test LDAP Source"""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -8,12 +8,12 @@ from docker.types import Healthcheck
|
||||
from authentik.lib.generators import generate_id
|
||||
from authentik.lib.utils.http import get_http_session
|
||||
from authentik.sources.scim.models import SCIMSource
|
||||
from tests.e2e.utils import SeleniumTestCase, retry
|
||||
from tests.e2e.utils import E2ETestCase, retry
|
||||
|
||||
TEST_POLL_MAX = 25
|
||||
|
||||
|
||||
class TestSourceSCIM(SeleniumTestCase):
|
||||
class TestSourceSCIM(E2ETestCase):
|
||||
"""test SCIM Source flow"""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
+28
-19
@@ -64,11 +64,8 @@ def get_local_ip(override=True) -> str:
|
||||
return "0.0.0.0"
|
||||
|
||||
|
||||
class SeleniumTestCase(DockerTestCase, StaticLiveServerTestCase):
|
||||
"""StaticLiveServerTestCase which automatically creates a Webdriver instance"""
|
||||
|
||||
class E2ETestCase(DockerTestCase, StaticLiveServerTestCase):
|
||||
host = get_local_ip()
|
||||
wait_timeout: int
|
||||
user: User
|
||||
|
||||
def setUp(self):
|
||||
@@ -77,11 +74,36 @@ class SeleniumTestCase(DockerTestCase, StaticLiveServerTestCase):
|
||||
apps.get_app_config("authentik_tenants").ready()
|
||||
self.wait_timeout = 60
|
||||
self.logger = get_logger()
|
||||
self.user = create_test_admin_user()
|
||||
super().setUp()
|
||||
|
||||
@classmethod
|
||||
def _pre_setup(cls):
|
||||
use_test_broker()
|
||||
return super()._pre_setup()
|
||||
|
||||
def _post_teardown(self):
|
||||
broker = get_broker()
|
||||
broker.flush_all()
|
||||
broker.close()
|
||||
return super()._post_teardown()
|
||||
|
||||
def tearDown(self):
|
||||
if IS_CI:
|
||||
print("::endgroup::", file=stderr)
|
||||
super().tearDown()
|
||||
|
||||
|
||||
class SeleniumTestCase(E2ETestCase):
|
||||
"""StaticLiveServerTestCase which automatically creates a Webdriver instance"""
|
||||
|
||||
wait_timeout: int
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.driver = self._get_driver()
|
||||
self.driver.implicitly_wait(30)
|
||||
self.wait = WebDriverWait(self.driver, self.wait_timeout)
|
||||
self.user = create_test_admin_user()
|
||||
super().setUp()
|
||||
|
||||
def _get_driver(self) -> WebDriver:
|
||||
count = 0
|
||||
@@ -135,20 +157,7 @@ class SeleniumTestCase(DockerTestCase, StaticLiveServerTestCase):
|
||||
def driver_container(self) -> Container:
|
||||
return self.docker_client.containers.list(filters={"label": "io.goauthentik.tests"})[0]
|
||||
|
||||
@classmethod
|
||||
def _pre_setup(cls):
|
||||
use_test_broker()
|
||||
return super()._pre_setup()
|
||||
|
||||
def _post_teardown(self):
|
||||
broker = get_broker()
|
||||
broker.flush_all()
|
||||
broker.close()
|
||||
return super()._post_teardown()
|
||||
|
||||
def tearDown(self):
|
||||
if IS_CI:
|
||||
print("::endgroup::", file=stderr)
|
||||
super().tearDown()
|
||||
if IS_CI:
|
||||
print("::group::Browser logs")
|
||||
|
||||
Reference in New Issue
Block a user