Files
commander/backend/test/accounts.test.ts
2026-10-27 12:42:57 +01:00

14 lines
602 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { hashPassword, verifyPassword } from '../src/accounts.js'
test('passwords are salted and verified', async () => {
const first = await hashPassword('correct horse battery staple')
const second = await hashPassword('correct horse battery staple')
assert.notEqual(first.salt, second.salt)
assert.notEqual(first.hash, second.hash)
assert.equal(await verifyPassword('correct horse battery staple', first.salt, first.hash), true)
assert.equal(await verifyPassword('wrong password', first.salt, first.hash), false)
})