test: add comprehensive e2e test suite with shared helpers and DB seeding

Extract shared test runner (helpers.js), add file-based SQLite with
setup_db.py for fixture seeding, and add tests for auth guard, credentials
management, full registration flow, health endpoint, password auth, and
magic link registration errors. 66 checks across 7 test files.
This commit is contained in:
Johan Lundberg 2026-02-16 14:41:14 +01:00
parent dbd7449ea1
commit c381896de4
No known key found for this signature in database
GPG key ID: A6C152738D03C7D1
10 changed files with 422 additions and 30 deletions

View file

@ -16,11 +16,16 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
PORT="${E2E_PORT:-8099}"
export TARGET_URL="http://127.0.0.1:${PORT}"
# --- Temp directory for e2e state ---
E2E_TMPDIR="$(mktemp -d)"
export OIDC_OP_SQLITE_PATH="${E2E_TMPDIR}/e2e_test.db"
export OIDC_OP_SIGNING_KEY_PATH="${E2E_TMPDIR}/keys"
# --- Start the app ---
echo "Starting Porchlight on port ${PORT}..."
echo " DB: ${OIDC_OP_SQLITE_PATH}"
OIDC_OP_ISSUER="${TARGET_URL}" \
OIDC_OP_DEBUG=true \
OIDC_OP_SQLITE_PATH=:memory: \
uv run --directory "$PROJECT_ROOT" \
uvicorn fastapi_oidc_op.app:create_app \
--factory --host 127.0.0.1 --port "$PORT" \
@ -31,6 +36,7 @@ cleanup() {
echo "Stopping server (pid ${SERVER_PID})..."
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
rm -rf "$E2E_TMPDIR"
}
trap cleanup EXIT
@ -48,6 +54,12 @@ for i in $(seq 1 30); do
sleep 1
done
# --- Seed test data ---
echo "Seeding test data..."
E2E_FIXTURES=$(uv run --directory "$PROJECT_ROOT" python tests/e2e/setup_db.py)
export E2E_FIXTURES
echo "Test fixtures: ${E2E_FIXTURES}"
# --- Run tests ---
FAILED=0