Test account and integration tests

Related: cognito-and-auth · secrets-and-configuration · troubleshooting-decisions

Shared test account (committed, not secret)

File: villa_backend_sdk/testing/cognito_test_account.json

FieldValue
Usernamevilla-sdk-test@villamarket.dev
PasswordVillaSdkTest2026!
User poolvillaMembers2 (ap-southeast-1_bul3MgmNE)
App clientvilla-backend-sdk-dev

Helper: villa_backend_sdk/testing/cognito_test.pyensure_test_user_registered()

How integration tests get a JWT

Fixture in tests/integration/conftest.py (session-scoped):

1. Try login() with fixture credentials

2. If login fails, call public **SignUp** (no IAM admin)

3. Attach Cognito **IdToken** as Authorization: Bearer … on all HTTP calls via integration_client

Unit tests stay fully mocked. Tests using integration_client always carry a real JWT when VILLA_COGNITO_CLIENT_SECRET is set.

One-time setup

After SignUp, confirm the shared user once in AWS Console:

**Cognito → villaMembers2 → Users → villa-sdk-test@villamarket.dev → Confirm user**

Or use email code: client.auth.confirm_sign_up(username, code).

Scripts

python3 scripts/provision_cognito_test_user.py
python3 scripts/smoke_test_cognito_login.py
pytest tests/integration -m integration -v

CI

GitHub Actions integration job needs repository secret VILLA_COGNITO_CLIENT_SECRET.

See also: docs/COGNITO_TEST.md, docs/TESTING.md.