From d785998c5a1590859e2ae05826bc0e97c10f9199 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Nov 2021 18:46:51 +0100 Subject: [PATCH] Revert "root: disable random tests for now" This reverts commit 8ba9553220c422107a249799f3def0cebeb89aad. --- Pipfile | 2 ++ Pipfile.lock | 29 +++++++++++++++++++++++++++-- authentik/core/tests/utils.py | 1 + authentik/root/test_runner.py | 3 ++- tests/e2e/utils.py | 4 ++-- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Pipfile b/Pipfile index 1a3866c25..4dd8b82d8 100644 --- a/Pipfile +++ b/Pipfile @@ -60,5 +60,7 @@ pylint = "*" pylint-django = "*" pytest = "*" pytest-django = "*" +pytest-randomly = "*" requests-mock = "*" selenium = "*" +importlib-metadata = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 22763e851..c4f8745ca 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "f9147b2f6e4cd3ec6cbe0dddbc22d3867c110cd26d2276644deb06c27631a6c3" + "sha256": "cb44f399eed2d9be5057c2c1ce572435b6a449cdfdf13abfee8787db1f2856d9" }, "pipfile-spec": 6, "requires": {}, @@ -317,7 +317,7 @@ "sha256:a0713dc7a1de3f06bc0df5a9567ad19ead2d3d5689b434768a6145bff77c0667", "sha256:f184f0d851d96b6d29297354ed981b7dd71df7ff500d82fa6d11f0856bee8035" ], - "markers": "python_version < '4' and python_full_version >= '3.6.2'", + "markers": "python_full_version >= '3.6.2' and python_full_version < '4.0.0'", "version": "==0.3.0" }, "click-plugins": { @@ -1364,6 +1364,7 @@ "version": "==2.7.4" }, "twisted": { + "extras": [], "hashes": [ "sha256:13c1d1d2421ae556d91e81e66cf0d4f4e4e1e4a36a0486933bee4305c6a4fb9b", "sha256:2cd652542463277378b0d349f47c62f20d9306e57d1247baabd6d1d38a109006" @@ -1996,6 +1997,14 @@ ], "version": "==3.3" }, + "importlib-metadata": { + "hashes": [ + "sha256:53ccfd5c134223e497627b9815d5030edf77d2ed573922f7a0b8f8bb81a1c100", + "sha256:75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb" + ], + "index": "pypi", + "version": "==4.8.2" + }, "iniconfig": { "hashes": [ "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", @@ -2170,6 +2179,14 @@ "index": "pypi", "version": "==4.4.0" }, + "pytest-randomly": { + "hashes": [ + "sha256:2c0a332c4b124e372e2473803bcc91ec87797664f4955afef2b844c0021662b1", + "sha256:cbd5c50b7c41491c202c71a3df33a75619d610a4f5c34aa2bd02ac30fce7cd43" + ], + "index": "pypi", + "version": "==3.10.2" + }, "pyyaml": { "hashes": [ "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", @@ -2448,6 +2465,14 @@ ], "markers": "python_full_version >= '3.6.1'", "version": "==1.0.0" + }, + "zipp": { + "hashes": [ + "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832", + "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc" + ], + "markers": "python_version >= '3.6'", + "version": "==3.6.0" } } } diff --git a/authentik/core/tests/utils.py b/authentik/core/tests/utils.py index 6f4199a02..bd67ee909 100644 --- a/authentik/core/tests/utils.py +++ b/authentik/core/tests/utils.py @@ -31,6 +31,7 @@ def create_test_admin_user(name: Optional[str] = None) -> User: name=uid, email=f"{uid}@goauthentik.io", ) + user.set_password(uid) group.users.add(user) return user diff --git a/authentik/root/test_runner.py b/authentik/root/test_runner.py index 69473bd50..3033cb90a 100644 --- a/authentik/root/test_runner.py +++ b/authentik/root/test_runner.py @@ -40,7 +40,8 @@ class PytestTestRunner: # pragma: no cover if self.keepdb: argv.append("--reuse-db") - argv.append("-pno:randomly") + 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/utils.py b/tests/e2e/utils.py index 2a5b7952c..bfebd8319 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -6,8 +6,8 @@ from os import environ, makedirs from time import sleep, time from typing import Any, Callable, Optional +from channels.testing import ChannelsLiveServerTestCase from django.apps import apps -from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.db import connection from django.db.migrations.loader import MigrationLoader from django.db.migrations.operations.special import RunPython @@ -48,7 +48,7 @@ def get_docker_tag() -> str: return f"gh-{branch_name}" -class SeleniumTestCase(StaticLiveServerTestCase): +class SeleniumTestCase(ChannelsLiveServerTestCase): """StaticLiveServerTestCase which automatically creates a Webdriver instance""" container: Optional[Container] = None