mirror of
https://github.com/hanzoai/node-jsonwebtoken.git
synced 2026-09-24 17:00:48 +00:00
use the same timestamp in sync and async
This commit is contained in:
@@ -6,10 +6,12 @@ describe('signing a token asynchronously', function() {
|
||||
|
||||
describe('when signing a token', function() {
|
||||
var secret = 'shhhhhh';
|
||||
var syncToken = jwt.sign({ foo: 'bar' }, secret, { algorithm: 'HS256' });
|
||||
//use the same timestamp, or it may differ in the two tokens
|
||||
var currentTimestamp = Math.floor(new Date()/1000);
|
||||
var syncToken = jwt.sign({ foo: 'bar', iat: currentTimestamp }, secret, { algorithm: 'HS256' });
|
||||
|
||||
it('should return the same result as singing synchronously', function(done) {
|
||||
jwt.sign({ foo: 'bar' }, secret, { algorithm: 'HS256' }, function (asyncToken) {
|
||||
jwt.sign({ foo: 'bar', iat: currentTimestamp }, secret, { algorithm: 'HS256' }, function (asyncToken) {
|
||||
expect(asyncToken).to.be.a('string');
|
||||
expect(asyncToken.split('.')).to.have.length(3);
|
||||
expect(asyncToken).to.equal(syncToken);
|
||||
|
||||
Reference in New Issue
Block a user