Add hashing y verificación de contraseña

This commit is contained in:
Carlos Narro
2026-05-30 19:32:28 +02:00
parent 5fb0d571cd
commit 49b5910593
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import { describe, it, expect } from 'vitest';
import { hashPassword, verifyPassword } from '@/lib/auth/password';
describe('password', () => {
it('verifica una contraseña correcta contra su hash', async () => {
const hash = await hashPassword('Reforma2026!');
expect(hash).not.toBe('Reforma2026!');
expect(await verifyPassword('Reforma2026!', hash)).toBe(true);
});
it('rechaza una contraseña incorrecta', async () => {
const hash = await hashPassword('Reforma2026!');
expect(await verifyPassword('otra', hash)).toBe(false);
});
});