19 lines
770 B
TypeScript
19 lines
770 B
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { PasswordService } from '../../src/auth/services/password.service';
|
|
|
|
test('PasswordService hashes with Argon2id and verifies safely', async () => {
|
|
const service = new PasswordService();
|
|
const hash = await service.hash('Una-clave-segura-2026');
|
|
|
|
assert.match(hash, /^\$argon2id\$/);
|
|
assert.equal(await service.verify(hash, 'Una-clave-segura-2026'), true);
|
|
assert.equal(await service.verify(hash, 'clave-incorrecta'), false);
|
|
assert.equal(service.needsRehash(hash), false);
|
|
});
|
|
|
|
test('PasswordService performs dummy verification for unknown users', async () => {
|
|
const service = new PasswordService();
|
|
await assert.doesNotReject(service.verifyUnknown('cualquier-clave'));
|
|
});
|