Skip to content

Commit

Permalink
test: check kid/thumbprint is not the same when kid is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 23, 2019
1 parent a8ef20e commit 4ace4be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/jwk/sanity.test.js → test/jwk/general.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('ava')

const { JWK: { generateSync, isKey } } = require('../..')
const { JWK: { generateSync, isKey, importKey } } = require('../..')

test('.isKey() only key objects return true', t => {
;[[], false, true, null, Infinity, 0].forEach((val) => {
Expand Down Expand Up @@ -37,3 +37,10 @@ test('"kid" must be a non-empty string', t => {
)
})
})

test('"kid" from JWK is used when available and its different from thumbprint', t => {
const { kid: generatedThumbprint, ...jwk } = generateSync('oct').toJWK(true)
const key = importKey({ ...jwk, kid: 'foo' })
t.is(key.kid, 'foo')
t.is(key.thumbprint, generatedThumbprint)
})

0 comments on commit 4ace4be

Please sign in to comment.