Scaffold project and implement config, DB schema/queries
- Set up package.json (ESM, scripts), tsconfig.json, vitest.config.ts - Install runtime and dev dependencies - Add CLAUDE.md with architecture notes and code quality rules - Config module with env var parsing and JWT_SECRET validation - DB schema: users + files tables with FK cascade - DB queries: createUser, getUserBy*, createFile, getFileById, getFilesByUserId, deleteFile - Tests for config, db/users, db/files (15 tests passing) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
tests/unit/auth-service.test.ts
Normal file
21
tests/unit/auth-service.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { hashPassword, verifyPassword } from '../../src/services/auth.ts';
|
||||
|
||||
describe('services/auth - password hashing', () => {
|
||||
it('hashes a password and verifies it', async () => {
|
||||
const hash = await hashPassword('mysecret');
|
||||
expect(hash).not.toBe('mysecret');
|
||||
await expect(verifyPassword('mysecret', hash)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('rejects wrong password', async () => {
|
||||
const hash = await hashPassword('mysecret');
|
||||
await expect(verifyPassword('wrong', hash)).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('produces different hashes for same password', async () => {
|
||||
const h1 = await hashPassword('same');
|
||||
const h2 = await hashPassword('same');
|
||||
expect(h1).not.toBe(h2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user