implement remove_user in authentik

This commit is contained in:
Daniel 2023-12-14 13:15:17 +01:00
parent b13303d404
commit baf6f6a655
2 changed files with 17 additions and 7 deletions

View file

@ -1,5 +1,6 @@
import json
import os
import re
from playwright.sync_api import BrowserContext
@ -11,8 +12,19 @@ TEST_USER = os.environ["TEST_USER"]
TEST_PASS = os.environ["TEST_PASS"]
def remove_user():
pass
def remove_user(admin_context: BrowserContext, URL: BaseUrl):
"""removes TEST_USER account from authentik"""
page = admin_context.new_page()
page.goto(URL.get())
page.get_by_role("link", name="Admin Interface").click()
nav = page.locator("ak-sidebar-item", has_text=re.compile(r"Directory|Verzeichnis"))
nav.click()
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
name_pattern = re.compile(TEST_USER)
page.get_by_role("row", name=name_pattern).get_by_label("").check()
page.get_by_role("button", name=re.compile(r"Löschen|Delete")).click()
page.get_by_role("dialog").get_by_role("button", name=re.compile(r"Löschen|Delete")).click()
def cleanup_delete_user(
@ -24,7 +36,5 @@ def cleanup_delete_user(
context.add_cookies(storage_state["cookies"])
if check_if_user_exists(context, env_config, URL):
# just login with user
assert False, "yes"
remove_user()
assert False, "no"
remove_user(context, URL)
assert not check_if_user_exists(context, env_config, URL)

View file

@ -5,4 +5,4 @@ class RunnerAuthentik(Runner):
env_type = "authentik"
setups = [Test(test_file="setup_authentik.py")]
tests = [Test(test_file="test_authentik_blueprint_api.py")]
cleanups = [Test(test_file="cleanup_authentik.py", prevent_skip=True)]
cleanups = [Test(test_file="cleanup_authentik.py")]