add a few more tests
This commit is contained in:
parent
5060c505b6
commit
e6de23532b
|
@ -23,7 +23,8 @@ keyfetch.oidcJwks(testIss).then(function (hits) {
|
|||
/*global Promise*/
|
||||
var keypairs = require('keypairs.js');
|
||||
keypairs.generate().then(function (pair) {
|
||||
return keypairs.signJwt({
|
||||
return Promise.all([
|
||||
keypairs.signJwt({
|
||||
jwk: pair.private, iss: 'https://example.com/', sub: 'mikey', exp: '1h'
|
||||
}).then(function (jwt) {
|
||||
return Promise.all([
|
||||
|
@ -52,6 +53,19 @@ keypairs.generate().then(function (pair) {
|
|||
, keyfetch.jwt.verify(jwt, { jwk: pair.public, claims: { iss: 'https://example.com/' } })
|
||||
, keyfetch.jwt.verify(jwt, { jwk: pair.public, claims: { iss: 'https://example.com' } })
|
||||
.then(e("inexact claim")).catch(throwIfNotExpected)
|
||||
]);
|
||||
})
|
||||
, keypairs.signJwt({
|
||||
jwk: pair.private, iss: false, sub: 'mikey', exp: '1h'
|
||||
}).then(function (jwt) {
|
||||
return Promise.all([
|
||||
keyfetch.jwt.verify(jwt, { jwk: pair.public })
|
||||
, keyfetch.jwt.verify(jwt)
|
||||
.then(e("should have an issuer")).catch(throwIfNotExpected)
|
||||
, keyfetch.jwt.verify(jwt, { jwk: pair.public, issuers: ['https://example.com/'] })
|
||||
.then(e("fail when issuer specified and doesn't exist")).catch(throwIfNotExpected)
|
||||
]);
|
||||
})
|
||||
]).then(function () {
|
||||
console.log("JWT PASSES");
|
||||
}).catch(function (err) {
|
||||
|
@ -60,7 +74,6 @@ keypairs.generate().then(function (pair) {
|
|||
process.exit(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
/*
|
||||
var jwt = '...';
|
||||
keyfetch.verify({ jwt: jwt }).catch(function (err) {
|
||||
|
|
Loading…
Reference in New Issue