From 76a79c11b22846db97b15d9843ffb7f45907e9cd Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2023 18:08:47 +0100 Subject: [PATCH] move credentials to environment variables, defined in main --- main.py | 8 ++++++++ src/tests_authentik/setup_authentik.py | 14 +++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index dc2a66c..00903eb 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import json import os from pathlib import Path @@ -17,6 +18,13 @@ TESTS_DIR = Path("./tests").resolve() # os.environ["PWDEBUG"] = "1" os.environ["TESTS_DIR"] = str(TESTS_DIR) +cred_file = Path("credentials.json") +with open(cred_file, "r") as f: + CREDENTIALS = json.load(f) + +os.environ["ADMIN_USER"] = CREDENTIALS["admin_user"] +os.environ["ADMIN_PASS"] = CREDENTIALS["admin_pass"] + session_id = get_session_id() wrapper = Wrapper(ENV_FILES, session_id=session_id) diff --git a/src/tests_authentik/setup_authentik.py b/src/tests_authentik/setup_authentik.py index 09495d3..713a8b5 100644 --- a/src/tests_authentik/setup_authentik.py +++ b/src/tests_authentik/setup_authentik.py @@ -1,15 +1,11 @@ import json +import os from pathlib import Path -from icecream import ic from playwright.sync_api import BrowserContext, expect -cred_file = Path("credentials.json") -with open(cred_file, "r") as f: - CREDENTIALS = json.load(f) - -ic("RUNNING SETUP") -ic(CREDENTIALS) +ADMIN_USER = os.environ["ADMIN_USER"] +ADMIN_PASS = os.environ["ADMIN_PASS"] TESTUSER = {"username": "testuser", "name": "Test User", "password": "test123", "email": "test@example.com"} TIMEOUT = 5000 @@ -27,8 +23,8 @@ def test_create_admin_login(context: BrowserContext, dotenv_config: dict[str, st expect(page.get_by_text(welcome_message)).to_be_visible(timeout=TIMEOUT) # login - page.locator('input[name="uidField"]').fill(CREDENTIALS["admin"]) - page.locator('ak-stage-identification input[name="password"]').fill(CREDENTIALS["admin_pw"]) + page.locator('input[name="uidField"]').fill(ADMIN_USER) + page.locator('ak-stage-identification input[name="password"]').fill(ADMIN_USER) page.get_by_role("button", name="Log In").click() expect(page.locator("ak-library")).to_be_visible(timeout=TIMEOUT)