diff --git a/recipes/authentik/tests_authentik/cleanup_authentik.py b/recipes/authentik/tests_authentik/cleanup_authentik.py new file mode 100644 index 0000000..3d65308 --- /dev/null +++ b/recipes/authentik/tests_authentik/cleanup_authentik.py @@ -0,0 +1,30 @@ +import json +import os + +from playwright.sync_api import BrowserContext + +from pytest_abra import BaseUrl, DirManager + +ADMIN_USER = os.environ["ADMIN_USER"] +ADMIN_PASS = os.environ["ADMIN_PASS"] +TEST_USER = os.environ["TEST_USER"] +TEST_PASS = os.environ["TEST_PASS"] + + +def remove_user(): + pass + + +def cleanup_delete_user( + context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl, check_if_user_exists +): + # load admin cookies to context + state_file = DIR.STATES / "authentik_admin_state.json" + storage_state = json.loads(state_file.read_bytes()) + 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" diff --git a/recipes/authentik/tests_authentik/runner_authentik.py b/recipes/authentik/tests_authentik/runner_authentik.py index 2543dc6..1079409 100644 --- a/recipes/authentik/tests_authentik/runner_authentik.py +++ b/recipes/authentik/tests_authentik/runner_authentik.py @@ -5,3 +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)]