Builds on Module 12's JWT authentication API by adding real front-end pages for login and registration, connecting them to the existing /auth/register and /auth/login endpoints, and adding genuine Playwright browser-automation E2E tests covering both successful and failing auth flows. CI/CD continues to run tests, scan for vulnerabilities, and deploy to Docker Hub on success.
login.html— username/password form. Client-side checks are minimal (non-empty fields only), consistent with the idea that login doesn't need to validate password strength, just that credentials were entered. On success, stores the access/refresh tokens inlocalStorageand redirects.register.html— username, email, first/last name, password, and confirm-password fields. Client-side validation includes:- Email format (regex)
- Password length (≥8 characters) and complexity (uppercase, lowercase, digit) — mirrors the server-side
PasswordMixinrules from Module 12 - Live password-match checking as the user types
- On success, redirects to
/loginrather than showing an in-page success message
Real browser-automation tests (not just HTTP requests) driving the actual login.html/register.html forms:
- Positive:
test_register_valid_data_shows_success— registers with valid data, confirms redirect to/logintest_login_valid_credentials_shows_success— registers, then logs in, confirms the success message and a real access token inlocalStorage
- Negative:
test_register_short_password_shows_error— confirms the front-end validation catches a short password before the request ever reaches the servertest_login_wrong_password_shows_error— confirms a401from the server surfaces as a visible "invalid credentials" message in the UI
A helper (wait_for_alert_or_fail_with_reason) reports which alert (success/error) actually appeared, or the current page state, if a test fails — making future failures self-diagnosing rather than a bare timeout.
- Client-side + server-side validation layering — client-side checks (instant feedback) mirror but don't replace server-side Pydantic validation (the actual security boundary)
- Factory Pattern —
Calculation.create(), carried over from Module 11 - Dependency Injection —
get_db(),get_current_user(),get_current_active_user() - In-process vs. subprocess testing — schema unit tests,
requests-based API tests, and Playwright browser tests each verify a different layer of the same auth flow
- ✅ JWT login/registration routes
- ✅ Front-end pages with client-side validation
- ✅ Playwright E2E tests, positive and negative scenarios
- ✅ CI/CD: test → security scan → deploy to Docker Hub
- Python 3.12
- Docker and Docker Compose
git clone git@github.com:enp23/assignment13.git
cd assignment13
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
docker compose up -d --buildpytest # full suite
pytest tests/e2e/ -v # Playwright + subprocess-based E2E tests only
pytest --cov=app --cov-report=term-missing # with coverage detailE2E tests run against a dedicated test database (fastapi_test_db), kept separate from fastapi_db via TEST_DATABASE_URL, passed explicitly to the subprocess test server.