setup_authentik almost wrunning
This commit is contained in:
parent
9d13e9a4aa
commit
e64e5e4bc9
1 changed files with 11 additions and 8 deletions
|
|
@ -21,6 +21,8 @@ def check_for(locator: Locator):
|
||||||
|
|
||||||
|
|
||||||
def setup_authentik(dotenv_config: dict[str, str], STATES: Path):
|
def setup_authentik(dotenv_config: dict[str, str], STATES: Path):
|
||||||
|
"""run directly as function from RUNNER"""
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = p.chromium.launch()
|
browser = p.chromium.launch()
|
||||||
admin_context = browser.new_context()
|
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 = browser.new_context()
|
||||||
user_context.set_default_timeout(TIMEOUT)
|
user_context.set_default_timeout(TIMEOUT)
|
||||||
create_admin_login(admin_context, dotenv_config, STATES)
|
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):
|
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
|
# save state
|
||||||
context.storage_state(path=f"{STATES}/admin_state.json")
|
context.storage_state(path=f"{STATES}/admin_state.json")
|
||||||
page.close()
|
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"]
|
url = "https://" + dotenv_config["DOMAIN"]
|
||||||
page.goto(url)
|
page.goto(url)
|
||||||
page.get_by_role("link", name="Admin Interface").click()
|
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):
|
def create_user(context: BrowserContext, invitelink, STATES: Path):
|
||||||
|
# warning: only works on german site
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto(invitelink)
|
page.goto(invitelink)
|
||||||
page.get_by_placeholder("Benutzername").click()
|
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")
|
context.storage_state(path=f"{STATES}/user_state.json")
|
||||||
|
|
||||||
|
|
||||||
def create_user_session(admin_context: BrowserContext, user_context: BrowserContext, STATES: Path):
|
def create_user_session(
|
||||||
# admin_context = browser.new_context(storage_state=f"{STATES}/admin_state.json"))
|
admin_context: BrowserContext, user_context: BrowserContext, dotenv_config: dict[str, str], STATES: Path
|
||||||
# admin_context = setup_context(browser, f"{STATES}/admin_state.json")
|
):
|
||||||
admin_page = admin_context.new_page()
|
invitelink = create_invite_link(admin_context, dotenv_config)
|
||||||
invitelink = create_invite_link(admin_page)
|
|
||||||
|
|
||||||
# create user
|
# create user
|
||||||
create_user(user_context, invitelink, STATES)
|
create_user(user_context, invitelink, STATES)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue