import { describe, it, expect } from 'vitest' import { hashPassword, verifyPassword } from '../server/utils/password' describe('password hashing (scrypt)', () => { it('hashes and verifies the correct password', async () => { const hash = await hashPassword('secret123') expect(hash).toContain(':') expect(await verifyPassword('secret123', hash)).toBe(true) }) it('rejects a wrong password', async () => { const hash = await hashPassword('secret123') expect(await verifyPassword('wrong-pass', hash)).toBe(false) }) it('rejects a malformed stored hash', async () => { expect(await verifyPassword('secret123', 'no-separator')).toBe(false) expect(await verifyPassword('secret123', '')).toBe(false) }) it('produces a unique salt per call', async () => { const a = await hashPassword('secret123') const b = await hashPassword('secret123') expect(a).not.toBe(b) }) })