tests/e2e: ensure akadmin is not used

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-11-23 21:30:02 +01:00
parent b2d2e7cbc8
commit 060f19ce06
12 changed files with 122 additions and 126 deletions

View File

@ -17,7 +17,7 @@ from authentik.flows.models import Flow, FlowStageBinding
from authentik.stages.authenticator_static.models import AuthenticatorStaticStage
from authentik.stages.authenticator_totp.models import AuthenticatorTOTPStage
from authentik.stages.authenticator_validate.models import AuthenticatorValidateStage
from tests.e2e.utils import USER, SeleniumTestCase, apply_migration, retry
from tests.e2e.utils import SeleniumTestCase, apply_migration, retry
@skipUnless(platform.startswith("linux"), "requires local docker")
@ -32,8 +32,7 @@ class TestFlowsAuthenticator(SeleniumTestCase):
"""test flow with otp stages"""
sleep(1)
# Setup TOTP Device
user = USER()
device = TOTPDevice.objects.create(user=user, confirmed=True, digits=6)
device = TOTPDevice.objects.create(user=self.user, confirmed=True, digits=6)
flow: Flow = Flow.objects.get(slug="default-authentication-flow")
FlowStageBinding.objects.create(
@ -53,7 +52,7 @@ class TestFlowsAuthenticator(SeleniumTestCase):
code_stage.find_element(By.CSS_SELECTOR, "input[name=code]").send_keys(totp.token())
code_stage.find_element(By.CSS_SELECTOR, "input[name=code]").send_keys(Keys.ENTER)
self.wait_for_url(self.if_user_url("/library"))
self.assert_user(USER())
self.assert_user(self.user)
@retry()
@apply_migration("authentik_core", "0002_auto_20200523_1133_squashed_0011_provider_name_temp")
@ -68,7 +67,7 @@ class TestFlowsAuthenticator(SeleniumTestCase):
self.login()
self.wait_for_url(self.if_user_url("/library"))
self.assert_user(USER())
self.assert_user(self.user)
self.driver.get(
self.url(
@ -98,7 +97,7 @@ class TestFlowsAuthenticator(SeleniumTestCase):
totp_stage.find_element(By.CSS_SELECTOR, "input[name=code]").send_keys(Keys.ENTER)
sleep(3)
self.assertTrue(TOTPDevice.objects.filter(user=USER(), confirmed=True).exists())
self.assertTrue(TOTPDevice.objects.filter(user=self.user, confirmed=True).exists())
@retry()
@apply_migration("authentik_core", "0002_auto_20200523_1133_squashed_0011_provider_name_temp")
@ -113,7 +112,7 @@ class TestFlowsAuthenticator(SeleniumTestCase):
self.login()
self.wait_for_url(self.if_user_url("/library"))
self.assert_user(USER())
self.assert_user(self.user)
self.driver.get(
self.url(
@ -134,6 +133,6 @@ class TestFlowsAuthenticator(SeleniumTestCase):
self.wait_for_url(destination_url)
sleep(1)
self.assertTrue(StaticDevice.objects.filter(user=USER(), confirmed=True).exists())
device = StaticDevice.objects.filter(user=USER(), confirmed=True).first()
self.assertTrue(StaticDevice.objects.filter(user=self.user, confirmed=True).exists())
device = StaticDevice.objects.filter(user=self.user, confirmed=True).first()
self.assertTrue(StaticToken.objects.filter(token=token, device=device).exists())