/
ncit
/
c4panelmodel
Обзор
Документация
Войти
/
ncit
/
c4panelmodel
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
tests/setup.ts
31 строка
1 KB
ncit
feat: rewrite hooks.server.ts to use Supabase Auth
07 июн 2026, 19:32
07 июн 2026, 19:32
b6162ab
Код
Авторство
О чём код?
/** * Test setup helpers. * * Unit tests do not require a database. * Integration tests should import `createTestDb` / `destroyTestDb` and * point at a dedicated test database (e.g., `c4panel_test`). */ import { scryptSync, randomBytes } from 'node:crypto'; /** Hash a password using the same algorithm as the production auth module. */ export function hashTestPassword(password: string): string { const salt = randomBytes(16); const derived = scryptSync(password.normalize('NFKC'), salt, 64); return `${salt.toString('hex')}:${derived.toString('hex')}`; } /** Factory: generate a random email for tests. */ export function randomEmail(): string { return `test-${randomBytes(4).toString('hex')}@example.com`; } /** Factory: generate a test user payload. */ export function makeTestUser(overrides?: Partial<{ email: string; name: string; password: string }>) { return { email: overrides?.email ?? randomEmail(), name: overrides?.name ?? 'Test User', password: overrides?.password ?? 'TestPass1', passwordHash: hashTestPassword(overrides?.password ?? 'TestPass1') }; }