initial commit
This commit is contained in:
21
test/unit/password.spec.js
Normal file
21
test/unit/password.spec.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { hashPassword, verifyPassword } from '../../server/utils/password.js'
|
||||
|
||||
describe('password', () => {
|
||||
it('hashes and verifies', () => {
|
||||
const password = 'secret123'
|
||||
const stored = hashPassword(password)
|
||||
expect(stored).toContain(':')
|
||||
expect(verifyPassword(password, stored)).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects wrong password', () => {
|
||||
const stored = hashPassword('right')
|
||||
expect(verifyPassword('wrong', stored)).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects invalid stored format', () => {
|
||||
expect(verifyPassword('a', '')).toBe(false)
|
||||
expect(verifyPassword('a', 'nocolon')).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user