14 lines
602 B
TypeScript
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)
|
|
})
|