Prisma models per data-model.md: users (status enum, site-admin flag), user_identities (password provider now, OIDC later — subject is the stable user id), sessions (hashed ids), auth_tokens (hashed, single- use), plus rate_limits and mail_outbox for the upcoming M1 stories. UsersService creates accounts transactionally with Argon2id-hashed password identities (OWASP parameters, rehash detection) and maps uniqueness violations to field-level conflicts. Database-backed suites run when TEST_DATABASE_URL is set — locally against the dev db, in CI via a new postgres service container; shared auth schemas (username, password policy incl. common-password blocklist) ship with tests. Closes #10 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
18 lines
672 B
TypeScript
18 lines
672 B
TypeScript
import { execFileSync } from 'node:child_process';
|
|
|
|
/**
|
|
* Database-backed tests run only when TEST_DATABASE_URL is set (locally:
|
|
* the compose dev db on port 5434; in CI: the postgres service container).
|
|
* This setup pushes the current Prisma schema into that database once per
|
|
* test run; tests skip themselves when the variable is absent.
|
|
*/
|
|
export default function globalSetup(): void {
|
|
const url = process.env.TEST_DATABASE_URL;
|
|
if (!url) return;
|
|
execFileSync(
|
|
process.execPath,
|
|
[require.resolve('prisma/build/index.js'), 'db', 'push', '--skip-generate'],
|
|
{ env: { ...process.env, DATABASE_URL: url }, stdio: 'inherit', cwd: __dirname },
|
|
);
|
|
}
|