First commit
This commit is contained in:
13
backend/test/accounts.test.ts
Normal file
13
backend/test/accounts.test.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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)
|
||||
})
|
||||
Reference in New Issue
Block a user