authentik setup fully working
This commit is contained in:
parent
f8683ac322
commit
a07d593796
1 changed files with 9 additions and 14 deletions
|
|
@ -10,7 +10,7 @@ ADMIN_PASS = os.environ["ADMIN_PASS"]
|
||||||
|
|
||||||
|
|
||||||
TESTUSER = {"username": "testuser", "name": "Test User", "password": "test123", "email": "test@example.com"}
|
TESTUSER = {"username": "testuser", "name": "Test User", "password": "test123", "email": "test@example.com"}
|
||||||
TIMEOUT = 5000
|
TIMEOUT = 10000
|
||||||
|
|
||||||
|
|
||||||
def test_create_admin_login(context: BrowserContext, dotenv_config: dict[str, str], STATES: Path):
|
def test_create_admin_login(context: BrowserContext, dotenv_config: dict[str, str], STATES: Path):
|
||||||
|
|
@ -22,13 +22,13 @@ def test_create_admin_login(context: BrowserContext, dotenv_config: dict[str, st
|
||||||
# check welcome message
|
# check welcome message
|
||||||
welcome_message = dotenv_config.get("welcome_message")
|
welcome_message = dotenv_config.get("welcome_message")
|
||||||
if welcome_message:
|
if welcome_message:
|
||||||
expect(page.get_by_text(welcome_message)).to_be_visible(timeout=TIMEOUT)
|
expect(page.get_by_text(welcome_message)).to_be_visible()
|
||||||
|
|
||||||
# login
|
# login
|
||||||
page.locator('input[name="uidField"]').fill(ADMIN_USER)
|
page.locator('input[name="uidField"]').fill(ADMIN_USER)
|
||||||
page.locator('ak-stage-identification input[name="password"]').fill(ADMIN_PASS)
|
page.locator('ak-stage-identification input[name="password"]').fill(ADMIN_PASS)
|
||||||
page.get_by_role("button", name="Log In").click()
|
page.get_by_role("button", name="Log In").click()
|
||||||
expect(page.locator("ak-library")).to_be_visible(timeout=TIMEOUT)
|
expect(page.locator("ak-library")).to_be_visible()
|
||||||
|
|
||||||
# save state
|
# save state
|
||||||
context.storage_state(path=f"{STATES}/admin_state.json")
|
context.storage_state(path=f"{STATES}/admin_state.json")
|
||||||
|
|
@ -40,9 +40,9 @@ def create_invite_link(admin_context: BrowserContext, dotenv_config: dict[str, s
|
||||||
page.goto(url)
|
page.goto(url)
|
||||||
page.get_by_role("link", name="Admin Interface").click()
|
page.get_by_role("link", name="Admin Interface").click()
|
||||||
|
|
||||||
# regex approach (shorter)
|
# regex approach (shorter):
|
||||||
page.get_by_role("button", name=re.compile(r"Directory|Verzeichnis")).click()
|
page.get_by_role("button", name=re.compile(r"Directory|Verzeichnis")).click()
|
||||||
# the or approach
|
# the or approach:
|
||||||
# button_dir_en = page.get_by_role("button", name="Directory")
|
# button_dir_en = page.get_by_role("button", name="Directory")
|
||||||
# page.get_by_role("button").get_by_text(re.compile("Verzeichnis|Directory")).click()
|
# page.get_by_role("button").get_by_text(re.compile("Verzeichnis|Directory")).click()
|
||||||
# button_dir_de = page.get_by_text("Verzeichnis")
|
# button_dir_de = page.get_by_text("Verzeichnis")
|
||||||
|
|
@ -51,13 +51,10 @@ def create_invite_link(admin_context: BrowserContext, dotenv_config: dict[str, s
|
||||||
nav = page.locator("ak-sidebar-item", has_text=re.compile(r"Directory|Verzeichnis"))
|
nav = page.locator("ak-sidebar-item", has_text=re.compile(r"Directory|Verzeichnis"))
|
||||||
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
|
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
|
||||||
|
|
||||||
nav = page.locator("ak-sidebar-item", has_text="Directory")
|
nav = page.locator("ak-sidebar-item", has_text=re.compile(r"Directory|Verzeichnis"))
|
||||||
nav.get_by_role("link", name=re.compile(r"Invitations|Einladungen")).click()
|
nav.get_by_role("link", name=re.compile(r"Invitations|Einladungen")).click()
|
||||||
|
|
||||||
# button_invitation_en = page.get_by_role("link", name="Invitations")
|
# todo: only works if no links have been created yet (empty list)
|
||||||
# button_invitation_de = page.get_by_text("Einladungen")
|
|
||||||
# button_invitation_en.or_(button_invitation_de).click()
|
|
||||||
|
|
||||||
page.get_by_role("cell", name=re.compile(r"Keine Objekte|objects")).get_by_role(
|
page.get_by_role("cell", name=re.compile(r"Keine Objekte|objects")).get_by_role(
|
||||||
"button"
|
"button"
|
||||||
).click() # todo: confirm "objects" for en lang
|
).click() # todo: confirm "objects" for en lang
|
||||||
|
|
@ -68,8 +65,8 @@ def create_invite_link(admin_context: BrowserContext, dotenv_config: dict[str, s
|
||||||
page.get_by_placeholder("Wählen Sie ein Objekt aus.").click()
|
page.get_by_placeholder("Wählen Sie ein Objekt aus.").click()
|
||||||
page.get_by_role("option", name=re.compile(r"invitation-enrollment-flow")).click()
|
page.get_by_role("option", name=re.compile(r"invitation-enrollment-flow")).click()
|
||||||
|
|
||||||
page.get_by_role("dialog").get_by_role("button", name=re.compile(r"Erstellen|create")).click() # confirm "create"
|
# force, because else we get "intercepts pointer events"
|
||||||
# page.get_by_text("Erstellen", exact=True).first.click()
|
page.locator("footer").locator("ak-spinner-button").first.click(force=True)
|
||||||
|
|
||||||
linklocator = page.get_by_role("rowgroup").filter(has=page.get_by_text(linkname))
|
linklocator = page.get_by_role("rowgroup").filter(has=page.get_by_text(linkname))
|
||||||
linklocator.locator(".fa-angle-down").click()
|
linklocator.locator(".fa-angle-down").click()
|
||||||
|
|
@ -109,7 +106,5 @@ def test_create_user_session(context: BrowserContext, dotenv_config: dict[str, s
|
||||||
|
|
||||||
# create user
|
# create user
|
||||||
context.clear_cookies()
|
context.clear_cookies()
|
||||||
# user_context = browser.new_context()
|
|
||||||
context.set_default_timeout(TIMEOUT)
|
|
||||||
create_user(context, invite_link, STATES)
|
create_user(context, invite_link, STATES)
|
||||||
context.storage_state(path=f"{STATES}/user_state.json")
|
context.storage_state(path=f"{STATES}/user_state.json")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue