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*/
|
/*global Promise*/
|
||||||
var keypairs = require('keypairs.js');
|
var keypairs = require('keypairs.js');
|
||||||
keypairs.generate().then(function (pair) {
|
keypairs.generate().then(function (pair) {
|
||||||
return keypairs.signJwt({
|
return Promise.all([
|
||||||
|
keypairs.signJwt({
|
||||||
jwk: pair.private, iss: 'https://example.com/', sub: 'mikey', exp: '1h'
|
jwk: pair.private, iss: 'https://example.com/', sub: 'mikey', exp: '1h'
|
||||||
}).then(function (jwt) {
|
}).then(function (jwt) {
|
||||||
return Promise.all([
|
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/' } })
|
||||||
, 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)
|
.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 () {
|
]).then(function () {
|
||||||
console.log("JWT PASSES");
|
console.log("JWT PASSES");
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
@ -60,7 +74,6 @@ keypairs.generate().then(function (pair) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
var jwt = '...';
|
var jwt = '...';
|
||||||
keyfetch.verify({ jwt: jwt }).catch(function (err) {
|
keyfetch.verify({ jwt: jwt }).catch(function (err) {
|
||||||
|
|
Loading…
Reference in New Issue