-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix #453: use nbf claim if present on body, solve false positive test related to nbf claim * feat: test back and forth jwt parsing to check consistency
- Loading branch information
1 parent
3e1a7a8
commit 3eaa791
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
|
||
const { createDecoder, createSigner } = require('../src') | ||
|
||
const secret = 'secret' | ||
const decoder = createDecoder({ key: secret }) | ||
const signer = createSigner({ key: secret }) | ||
|
||
test('Should encode and decode the token, keeping a consistent payload', t => { | ||
const p1 = { | ||
a: 20, | ||
iat: 999, | ||
exp: 200000 | ||
} | ||
t.strictSame(decoder(signer(p1)), p1) | ||
|
||
const p2 = { | ||
a: 'h', | ||
iat: 999, | ||
nbf: 999 | ||
} | ||
t.strictSame(decoder(signer(p2)), p2) | ||
|
||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters