authentik setup and tracing #2

Merged
dan merged 69 commits from working-setup into dev 2023-11-27 17:01:47 +01:00
Showing only changes of commit e64e5e4bc9 - Show all commits

View file

@ -21,6 +21,8 @@ def check_for(locator: Locator):
def setup_authentik(dotenv_config: dict[str, str], STATES: Path):
"""run directly as function from RUNNER"""
with sync_playwright() as p:
browser = p.chromium.launch()
admin_context = browser.new_context()
@ -28,7 +30,7 @@ def setup_authentik(dotenv_config: dict[str, str], STATES: Path):
user_context = browser.new_context()
user_context.set_default_timeout(TIMEOUT)
create_admin_login(admin_context, dotenv_config, STATES)
create_user_session(admin_context, user_context, STATES)
create_user_session(admin_context, user_context, dotenv_config, STATES)
def create_admin_login(context: BrowserContext, dotenv_config: dict[str, str], STATES: Path):
@ -51,10 +53,11 @@ def create_admin_login(context: BrowserContext, dotenv_config: dict[str, str], S
# save state
context.storage_state(path=f"{STATES}/admin_state.json")
page.close()
context.close()
# context.close()
def create_invite_link(page: Page, dotenv_config: dict[str, str]):
def create_invite_link(admin_context: BrowserContext, dotenv_config: dict[str, str]):
page = admin_context.new_page()
url = "https://" + dotenv_config["DOMAIN"]
page.goto(url)
page.get_by_role("link", name="Admin Interface").click()
@ -75,6 +78,7 @@ def create_invite_link(page: Page, dotenv_config: dict[str, str]):
def create_user(context: BrowserContext, invitelink, STATES: Path):
# warning: only works on german site
page = context.new_page()
page.goto(invitelink)
page.get_by_placeholder("Benutzername").click()
@ -92,11 +96,10 @@ def create_user(context: BrowserContext, invitelink, STATES: Path):
context.storage_state(path=f"{STATES}/user_state.json")
def create_user_session(admin_context: BrowserContext, user_context: BrowserContext, STATES: Path):
# 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)
def create_user_session(
admin_context: BrowserContext, user_context: BrowserContext, dotenv_config: dict[str, str], STATES: Path
):
invitelink = create_invite_link(admin_context, dotenv_config)
# create user
create_user(user_context, invitelink, STATES)