-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add complete option in jwt.verify #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,30 @@ describe('verify', function() { | |
| }); | ||
| }); | ||
|
|
||
| describe('option: complete', function() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I didn't realize about this before, can you follow similar approach as this option? That is: We are refactoring the tests moving towards that model so each option and claim has its own tests using common tooling.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved here 4d8f50a Apart from that, I added another unit test for |
||
| it('should return header, payload and signature', function (done) { | ||
| var header = { alg: 'RS256' }; | ||
| var payload = { iat: Math.floor(Date.now() / 1000 ) }; | ||
|
|
||
| var signed = jws.sign({ | ||
| header: header, | ||
| payload: payload, | ||
| secret: priv, | ||
| encoding: 'utf8' | ||
| }); | ||
|
|
||
| var signature = jws.decode(signed).signature; | ||
|
|
||
| jwt.verify(signed, pub, {typ: 'JWT', complete: true}, function(err, p) { | ||
| assert.isNull(err); | ||
| assert.deepEqual(p.header, header); | ||
| assert.deepEqual(p.payload, payload); | ||
| assert.deepEqual(p.signature, signature); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('secret or token as callback', function () { | ||
| var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpYXQiOjE0MzcwMTg1ODIsImV4cCI6MTQzNzAxODU5Mn0.3aR3vocmgRpG05rsI9MpR6z2T_BGtMQaPq2YR6QaroU'; | ||
| var key = 'key'; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.