tests/e2e: fix source tests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
69ee18e13d
commit
bfa0c46588
|
@ -15,6 +15,7 @@ from selenium.webdriver.support.wait import WebDriverWait
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
from yaml import safe_dump
|
from yaml import safe_dump
|
||||||
|
|
||||||
|
from authentik.core.models import User
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.providers.oauth2.generators import (
|
from authentik.providers.oauth2.generators import (
|
||||||
generate_client_id,
|
generate_client_id,
|
||||||
|
@ -162,17 +163,7 @@ class TestSourceOAuth2(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
self.assertEqual(
|
self.assert_user(User(username="foo", name="admin", email="admin@example.com"))
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_name").get_attribute("value"),
|
|
||||||
"admin",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_email").get_attribute("value"),
|
|
||||||
"admin@example.com",
|
|
||||||
)
|
|
||||||
|
|
||||||
@retry()
|
@retry()
|
||||||
@apply_migration("authentik_core", "0003_default_user")
|
@apply_migration("authentik_core", "0003_default_user")
|
||||||
|
@ -257,17 +248,7 @@ class TestSourceOAuth2(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
self.assertEqual(
|
self.assert_user(User(username="foo", name="admin", email="admin@example.com"))
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_name").get_attribute("value"),
|
|
||||||
"admin",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_email").get_attribute("value"),
|
|
||||||
"admin@example.com",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@skipUnless(platform.startswith("linux"), "requires local docker")
|
@skipUnless(platform.startswith("linux"), "requires local docker")
|
||||||
|
@ -361,15 +342,6 @@ class TestSourceOAuth1(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
self.assertEqual(
|
self.assert_user(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"),
|
User(username="example-user", name="test name", email="foo@example.com")
|
||||||
"example-user",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_name").get_attribute("value"),
|
|
||||||
"test name",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self.driver.find_element(By.ID, "id_email").get_attribute("value"),
|
|
||||||
"foo@example.com",
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,12 +5,14 @@ from typing import Any, Optional
|
||||||
from unittest.case import skipUnless
|
from unittest.case import skipUnless
|
||||||
|
|
||||||
from docker.types import Healthcheck
|
from docker.types import Healthcheck
|
||||||
|
from guardian.utils import get_anonymous_user
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
from selenium.webdriver.support import expected_conditions as ec
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
from selenium.webdriver.support.wait import WebDriverWait
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.core.models import User
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.sources.saml.models import SAMLBindingTypes, SAMLSource
|
from authentik.sources.saml.models import SAMLBindingTypes, SAMLSource
|
||||||
|
@ -155,9 +157,10 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
self.assert_user(
|
||||||
self.assertNotEqual(
|
User.objects.exclude(username="akadmin")
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), ""
|
.exclude(pk=get_anonymous_user().pk)
|
||||||
|
.first()
|
||||||
)
|
)
|
||||||
|
|
||||||
@retry()
|
@retry()
|
||||||
|
@ -235,9 +238,10 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
self.assert_user(
|
||||||
self.assertNotEqual(
|
User.objects.exclude(username="akadmin")
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), ""
|
.exclude(pk=get_anonymous_user().pk)
|
||||||
|
.first()
|
||||||
)
|
)
|
||||||
|
|
||||||
@retry()
|
@retry()
|
||||||
|
@ -302,7 +306,8 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.wait_for_url(self.if_admin_url("/library"))
|
self.wait_for_url(self.if_admin_url("/library"))
|
||||||
self.driver.get(self.if_admin_url("/user"))
|
self.driver.get(self.if_admin_url("/user"))
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
self.assert_user(
|
||||||
self.assertNotEqual(
|
User.objects.exclude(username="akadmin")
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), ""
|
.exclude(pk=get_anonymous_user().pk)
|
||||||
|
.first()
|
||||||
)
|
)
|
||||||
|
|
Reference in New Issue