Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Create the admin account from the example settings: check the admin address for format only ([email protected] has a null MX and stopped the container); the e2e defaults test now uses the example unchanged
Murtaza Nasir806108ac7177
diff --git a/scripts/docker_create_admin.py b/scripts/docker_create_admin.pyindex 124e0dfb..de7ef3f0 100644--- a/scripts/docker_create_admin.py+++ b/scripts/docker_create_admin.py@@ -50,10 +50,12 @@ def create_admin_user_from_env():print("Error: Username must be at least 3 characters long.")sys.exit(1)- # Validate email (skip DNS/MX check if SKIP_EMAIL_DOMAIN_CHECK=true)- skip_domain_check = os.environ.get('SKIP_EMAIL_DOMAIN_CHECK', 'false').lower() == 'true'+ # Validate the address format only. The administrator chose this address+ # in the environment, and a domain that does not receive mail (such as+ # the example.com placeholder in the example configuration) must not stop+ # the container from starting. Self-registration keeps the full check.try:- validate_email(email, check_deliverability=not skip_domain_check)+ validate_email(email, check_deliverability=False)except EmailNotValidError as e:print(f"Error: Invalid email: {str(e)}")sys.exit(1)diff --git a/tests/e2e/test_whisperx_defaults_e2e.py b/tests/e2e/test_whisperx_defaults_e2e.pyindex 13bf21c2..d34e4438 100644--- a/tests/e2e/test_whisperx_defaults_e2e.py+++ b/tests/e2e/test_whisperx_defaults_e2e.py@@ -108,10 +108,6 @@ def speakr():"TEXT_MODEL_BASE_URL": llm.url,"TEXT_MODEL_API_KEY": "e2e","PYTHONUNBUFFERED": "1",- # The example's admin address is rejected by the domain check (see- # test_the_example_admin_account_is_created); skip the check so the- # rest of the documented setup can be tested.- "SKIP_EMAIL_DOMAIN_CHECK": "true",})for d in ("uploads", "exports", "auto-process"):os.makedirs(os.path.join(work, d), exist_ok=True)@@ -246,10 +242,6 @@ def test_neither_service_logged_an_error(speakr, admin):assert not service_errors, "whisperx-asr-service logged errors:\n" + "\n".join(service_errors[:40])[email protected](strict=True, reason=(- "config/env.whisperx.example sets [email protected]; example.com publishes a null MX, so "- "scripts/docker_create_admin.py rejects it and docker-entrypoint.sh (set -e) stops. Remove this marker "- "once the example uses an address that passes, or sets SKIP_EMAIL_DOMAIN_CHECK."))def test_the_example_admin_account_is_created():"""The example's admin settings, exactly as a user copies them."""work = tempfile.mkdtemp(prefix="speakr-e2e-admin-")diff --git a/tests/test_docker_create_admin.py b/tests/test_docker_create_admin.pynew file mode 100644index 00000000..5a8ae3e1--- /dev/null+++ b/tests/test_docker_create_admin.py@@ -0,0 +1,51 @@+"""The admin account from the environment is created with the example settings.++Every example configuration sets [email protected]. example.com+publishes a null MX record, so a deliverability check rejected the address and+the container stopped at startup. The admin address is now checked for format+only; self-registration keeps the full check.+"""++import os+import shutil+import subprocess+import sys+import tempfile++ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+++def _run(email):+ work = tempfile.mkdtemp(prefix="speakr-admin-")+ try:+ env = {k: os.environ[k] for k in ("PATH", "HOME", "LANG") if k in os.environ}+ env.update({+ "SQLALCHEMY_DATABASE_URI": f"sqlite:///{work}/t.db",+ "UPLOAD_FOLDER": f"{work}/uploads",+ "SECRET_KEY": "admin-test",+ "TEXT_MODEL_API_KEY": "test-key",+ "TRANSCRIPTION_API_KEY": "test-key",+ "TRANSCRIPTION_BASE_URL": "https://api.openai.com/v1",+ "DISABLE_VOICE_EMBEDDING_CHECK": "true",+ "ENABLE_AUTO_PROCESSING": "false",+ "ADMIN_USERNAME": "admin",+ "ADMIN_EMAIL": email,+ "ADMIN_PASSWORD": "changeme-please",+ })+ subprocess.run([sys.executable, "-c", "from src.app import app, db; app.app_context().push(); db.create_all()"],+ cwd=ROOT, env=env, check=True, capture_output=True, timeout=300)+ return subprocess.run([sys.executable, "scripts/docker_create_admin.py"], cwd=ROOT, env=env,+ capture_output=True, text=True, timeout=300)+ finally:+ shutil.rmtree(work, ignore_errors=True)+++def test_the_example_admin_address_is_accepted():+ done = _run("[email protected]")+ assert done.returncode == 0, done.stdout[-800:] + done.stderr[-800:]+++def test_a_malformed_admin_address_is_still_rejected():+ done = _run("not-an-address")+ assert done.returncode == 1+ assert "Invalid email" in done.stdout