From b2d2e7cbc8be00975a2021b5cc28150a4e6c578b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Nov 2021 19:25:31 +0100 Subject: [PATCH] tests/e2e: remove logger Signed-off-by: Jens Langhammer --- authentik/core/tests/utils.py | 2 +- authentik/root/test_runner.py | 3 +++ tests/e2e/test_provider_ldap.py | 3 ++- tests/e2e/test_provider_oauth2_grafana.py | 3 --- tests/e2e/test_provider_oauth2_oidc.py | 5 +---- tests/e2e/test_provider_oauth2_oidc_implicit.py | 5 +---- tests/e2e/test_provider_saml.py | 5 +---- tests/e2e/test_source_oauth.py | 2 -- tests/e2e/test_source_saml.py | 3 --- 9 files changed, 9 insertions(+), 22 deletions(-) diff --git a/authentik/core/tests/utils.py b/authentik/core/tests/utils.py index 051667ec7..6539f7cae 100644 --- a/authentik/core/tests/utils.py +++ b/authentik/core/tests/utils.py @@ -22,7 +22,7 @@ def create_test_flow(designation: FlowDesignation = FlowDesignation.STAGE_CONFIG ) -def create_test_admin_user(name: Optional[str] = None, set_password = False) -> User: +def create_test_admin_user(name: Optional[str] = None, set_password=False) -> User: """Generate a test-admin user""" uid = generate_id(20) if not name else name group = Group.objects.create(name=uid, is_superuser=True) diff --git a/authentik/root/test_runner.py b/authentik/root/test_runner.py index 459bb4b64..3033cb90a 100644 --- a/authentik/root/test_runner.py +++ b/authentik/root/test_runner.py @@ -40,5 +40,8 @@ class PytestTestRunner: # pragma: no cover if self.keepdb: argv.append("--reuse-db") + if any("tests/e2e" in label for label in test_labels): + argv.append("-pno:randomly") + argv.extend(test_labels) return pytest.main(argv) diff --git a/tests/e2e/test_provider_ldap.py b/tests/e2e/test_provider_ldap.py index e8b67bdc4..59868507c 100644 --- a/tests/e2e/test_provider_ldap.py +++ b/tests/e2e/test_provider_ldap.py @@ -79,6 +79,7 @@ class TestProviderLDAP(SeleniumTestCase): break healthcheck_retries += 1 sleep(0.5) + sleep(5) return user, outpost @retry() @@ -196,7 +197,7 @@ class TestProviderLDAP(SeleniumTestCase): for obj in response: del obj["raw_attributes"] del obj["raw_dn"] - o_user = outpost.suer + o_user = outpost.user self.assertCountEqual( response, [ diff --git a/tests/e2e/test_provider_oauth2_grafana.py b/tests/e2e/test_provider_oauth2_grafana.py index b5f898a7c..6037921af 100644 --- a/tests/e2e/test_provider_oauth2_grafana.py +++ b/tests/e2e/test_provider_oauth2_grafana.py @@ -7,7 +7,6 @@ from unittest.case import skipUnless from docker.types import Healthcheck from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec -from structlog.stdlib import get_logger from authentik.core.models import Application from authentik.core.tests.utils import create_test_cert @@ -23,8 +22,6 @@ from authentik.providers.oauth2.constants import ( from authentik.providers.oauth2.models import ClientTypes, OAuth2Provider, ScopeMapping from tests.e2e.utils import USER, SeleniumTestCase, apply_migration, object_manager, retry -LOGGER = get_logger() - @skipUnless(platform.startswith("linux"), "requires local docker") class TestProviderOAuth2OAuth(SeleniumTestCase): diff --git a/tests/e2e/test_provider_oauth2_oidc.py b/tests/e2e/test_provider_oauth2_oidc.py index d29aed6ac..35eca332f 100644 --- a/tests/e2e/test_provider_oauth2_oidc.py +++ b/tests/e2e/test_provider_oauth2_oidc.py @@ -9,7 +9,6 @@ from docker.models.containers import Container from docker.types import Healthcheck from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec -from structlog.stdlib import get_logger from authentik.core.models import Application from authentik.core.tests.utils import create_test_cert @@ -25,8 +24,6 @@ from authentik.providers.oauth2.constants import ( from authentik.providers.oauth2.models import ClientTypes, OAuth2Provider, ScopeMapping from tests.e2e.utils import USER, SeleniumTestCase, apply_migration, object_manager, retry -LOGGER = get_logger() - @skipUnless(platform.startswith("linux"), "requires local docker") class TestProviderOAuth2OIDC(SeleniumTestCase): @@ -63,7 +60,7 @@ class TestProviderOAuth2OIDC(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container - LOGGER.info("Container failed healthcheck") + self.logger.info("Container failed healthcheck") sleep(1) @retry() diff --git a/tests/e2e/test_provider_oauth2_oidc_implicit.py b/tests/e2e/test_provider_oauth2_oidc_implicit.py index b31d60b4d..0d1b42ad1 100644 --- a/tests/e2e/test_provider_oauth2_oidc_implicit.py +++ b/tests/e2e/test_provider_oauth2_oidc_implicit.py @@ -9,7 +9,6 @@ from docker.models.containers import Container from docker.types import Healthcheck from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec -from structlog.stdlib import get_logger from authentik.core.models import Application from authentik.core.tests.utils import create_test_cert @@ -25,8 +24,6 @@ from authentik.providers.oauth2.constants import ( from authentik.providers.oauth2.models import ClientTypes, OAuth2Provider, ScopeMapping from tests.e2e.utils import USER, SeleniumTestCase, apply_migration, object_manager, retry -LOGGER = get_logger() - @skipUnless(platform.startswith("linux"), "requires local docker") class TestProviderOAuth2OIDCImplicit(SeleniumTestCase): @@ -63,7 +60,7 @@ class TestProviderOAuth2OIDCImplicit(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container - LOGGER.info("Container failed healthcheck") + self.logger.info("Container failed healthcheck") sleep(1) @retry() diff --git a/tests/e2e/test_provider_saml.py b/tests/e2e/test_provider_saml.py index fa37d045f..b4b5a9c26 100644 --- a/tests/e2e/test_provider_saml.py +++ b/tests/e2e/test_provider_saml.py @@ -9,7 +9,6 @@ from docker.models.containers import Container from docker.types import Healthcheck from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec -from structlog.stdlib import get_logger from authentik.core.models import Application from authentik.core.tests.utils import create_test_cert @@ -19,8 +18,6 @@ from authentik.policies.models import PolicyBinding from authentik.providers.saml.models import SAMLBindings, SAMLPropertyMapping, SAMLProvider from tests.e2e.utils import USER, SeleniumTestCase, apply_migration, object_manager, retry -LOGGER = get_logger() - @skipUnless(platform.startswith("linux"), "requires local docker") class TestProviderSAML(SeleniumTestCase): @@ -58,7 +55,7 @@ class TestProviderSAML(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container - LOGGER.info("Container failed healthcheck") + self.logger.info("Container failed healthcheck") sleep(1) @retry() diff --git a/tests/e2e/test_source_oauth.py b/tests/e2e/test_source_oauth.py index da7b04e33..642c27b96 100644 --- a/tests/e2e/test_source_oauth.py +++ b/tests/e2e/test_source_oauth.py @@ -12,7 +12,6 @@ from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.wait import WebDriverWait -from structlog.stdlib import get_logger from yaml import safe_dump from authentik.core.models import User @@ -25,7 +24,6 @@ from authentik.stages.identification.models import IdentificationStage from tests.e2e.utils import SeleniumTestCase, apply_migration, object_manager, retry CONFIG_PATH = "/tmp/dex.yml" # nosec -LOGGER = get_logger() class OAUth1Type(SourceType): diff --git a/tests/e2e/test_source_saml.py b/tests/e2e/test_source_saml.py index 6d9e3f1b1..f37b99b1a 100644 --- a/tests/e2e/test_source_saml.py +++ b/tests/e2e/test_source_saml.py @@ -10,7 +10,6 @@ from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.wait import WebDriverWait -from structlog.stdlib import get_logger from authentik.core.models import User from authentik.crypto.models import CertificateKeyPair @@ -19,8 +18,6 @@ from authentik.sources.saml.models import SAMLBindingTypes, SAMLSource from authentik.stages.identification.models import IdentificationStage from tests.e2e.utils import SeleniumTestCase, apply_migration, object_manager, retry -LOGGER = get_logger() - IDP_CERT = """-----BEGIN CERTIFICATE----- MIIDXTCCAkWgAwIBAgIJALmVVuDWu4NYMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX