mirror of
https://github.com/danbulant/jose
synced 2026-05-24 12:35:36 +00:00
test: add timingSafeEqual tests
This commit is contained in:
parent
bcd920600d
commit
44848fd879
1 changed files with 12 additions and 0 deletions
12
test/help/timing_safe_equal.test.js
Normal file
12
test/help/timing_safe_equal.test.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
const test = require('ava')
|
||||||
|
|
||||||
|
const timingSafeEqual = require('../../lib/help/timing_safe_equal')
|
||||||
|
|
||||||
|
test('same length buffers', t => {
|
||||||
|
t.is(true, timingSafeEqual(Buffer.from('foo'), Buffer.from('foo')))
|
||||||
|
t.is(false, timingSafeEqual(Buffer.from('foo'), Buffer.from('bar')))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('different length buffers', t => {
|
||||||
|
t.is(false, timingSafeEqual(Buffer.from('foo'), Buffer.from('barbaz')))
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue