WIP create user session in setup_authentik
This commit is contained in:
parent
48d44b945f
commit
665fd34ddd
1 changed files with 53 additions and 1 deletions
|
|
@ -20,7 +20,7 @@ def check_for(locator: Locator):
|
|||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def admin_login(browser: Browser, dotenv_config, STATES):
|
||||
def create_admin_login(browser: Browser, dotenv_config, STATES):
|
||||
# ic(dotenv_config)
|
||||
|
||||
# go to page
|
||||
|
|
@ -45,3 +45,55 @@ def admin_login(browser: Browser, dotenv_config, STATES):
|
|||
context.storage_state(path=f"{STATES}/admin_state.json")
|
||||
page.close()
|
||||
context.close()
|
||||
|
||||
|
||||
def create_invite_link(page):
|
||||
url = "https://" + dotenv_config["DOMAIN"]
|
||||
page.goto(url)
|
||||
page.get_by_role("link", name="Admin Interface").click()
|
||||
page.get_by_text("Verzeichnis").click()
|
||||
page.get_by_text("Benutzer").nth(2).click()
|
||||
page.get_by_text("Einladungen").click()
|
||||
page.get_by_role("button", name="Erstellen").first.click()
|
||||
page.locator('input[name="name"]').click()
|
||||
linkname = "testlink9433"
|
||||
page.locator('input[name="name"]').fill(linkname)
|
||||
page.get_by_placeholder("Wählen Sie ein Objekt aus.").click()
|
||||
page.get_by_role("option", name="invitation-enrollment-flow invitation-enrollment-flow").click()
|
||||
page.get_by_text("Erstellen", exact=True).first.click()
|
||||
linklocator = page.get_by_role("rowgroup").filter(has=page.get_by_text(linkname))
|
||||
linklocator.locator(".fa-angle-down").click()
|
||||
invitelink = linklocator.get_by_role("textbox").get_attribute(name="value")
|
||||
return invitelink
|
||||
|
||||
|
||||
def create_user(context, invitelink):
|
||||
page = context.new_page()
|
||||
page.goto(invitelink)
|
||||
page.get_by_placeholder("Benutzername").click()
|
||||
page.get_by_placeholder("Benutzername").fill(testuser["username"])
|
||||
page.locator("input[name=\"name\"]").click()
|
||||
page.locator("input[name=\"name\"]").fill(testuser["name"])
|
||||
page.locator("input[name=\"email\"]").click()
|
||||
page.locator("input[name=\"email\"]").fill(testuser["email"])
|
||||
page.get_by_placeholder("Passwort", exact=True).click()
|
||||
page.get_by_placeholder("Passwort", exact=True).fill(testuser["password"])
|
||||
page.get_by_placeholder("Passwort (wiederholen)").click()
|
||||
page.get_by_placeholder("Passwort (wiederholen)").fill(testuser["password"])
|
||||
page.get_by_role("button", name="Weiter").click()
|
||||
check_for(page.locator("ak-library"))
|
||||
context.storage_state(path=f"{STATES}/user_state.json")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def create_user_session(browser: Browser, admin_login):
|
||||
admin_context = browser.new_context(storage_state=f"{STATES}/admin_state.json"))
|
||||
# admin_context = setup_context(browser, f"{STATES}/admin_state.json")
|
||||
admin_page = admin_context.new_page()
|
||||
invitelink = create_invite_link(admin_page)
|
||||
admin_context.tracing.stop(path=f"{RECORDS}/create_invite_link.zip")
|
||||
admin_context.close()
|
||||
user_context = setup_context(browser)
|
||||
create_user(user_context, invitelink)
|
||||
user_context.tracing.stop(path=f"{RECORDS}/create_user.zip")
|
||||
user_context.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue