@@ -259,98 +259,107 @@ describe('RS256', function() {
259
259
describe ( 'when signing a token with issuer' , function ( ) {
260
260
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' , issuer : 'urn:foo' } ) ;
261
261
262
- it ( 'should check issuer' , function ( ) {
262
+ it ( 'should check issuer' , function ( done ) {
263
263
jwt . verify ( token , pub , { issuer : 'urn:foo' } , function ( err , decoded ) {
264
264
assert . isNotNull ( decoded ) ;
265
265
assert . isNull ( err ) ;
266
+ done ( ) ;
266
267
} ) ;
267
268
} ) ;
268
269
269
- it ( 'should throw when invalid issuer' , function ( ) {
270
+ it ( 'should throw when invalid issuer' , function ( done ) {
270
271
jwt . verify ( token , pub , { issuer : 'urn:wrong' } , function ( err , decoded ) {
271
272
assert . isUndefined ( decoded ) ;
272
273
assert . isNotNull ( err ) ;
273
274
assert . equal ( err . name , 'JsonWebTokenError' ) ;
274
275
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
276
+ done ( ) ;
275
277
} ) ;
276
278
} ) ;
277
279
} ) ;
278
280
279
281
describe ( 'when signing a token without issuer' , function ( ) {
280
282
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' } ) ;
281
283
282
- it ( 'should check issuer' , function ( ) {
284
+ it ( 'should check issuer' , function ( done ) {
283
285
jwt . verify ( token , pub , { issuer : 'urn:foo' } , function ( err , decoded ) {
284
286
assert . isUndefined ( decoded ) ;
285
287
assert . isNotNull ( err ) ;
286
288
assert . equal ( err . name , 'JsonWebTokenError' ) ;
287
289
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
290
+ done ( ) ;
288
291
} ) ;
289
292
} ) ;
290
293
} ) ;
291
294
292
295
describe ( 'when signing a token with subject' , function ( ) {
293
296
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' , subject : 'subject' } ) ;
294
297
295
- it ( 'should check subject' , function ( ) {
298
+ it ( 'should check subject' , function ( done ) {
296
299
jwt . verify ( token , pub , { subject : 'subject' } , function ( err , decoded ) {
297
300
assert . isNotNull ( decoded ) ;
298
301
assert . isNull ( err ) ;
302
+ done ( ) ;
299
303
} ) ;
300
304
} ) ;
301
305
302
- it ( 'should throw when invalid subject' , function ( ) {
303
- jwt . verify ( token , pub , { issuer : 'wrongSubject' } , function ( err , decoded ) {
306
+ it ( 'should throw when invalid subject' , function ( done ) {
307
+ jwt . verify ( token , pub , { subject : 'wrongSubject' } , function ( err , decoded ) {
304
308
assert . isUndefined ( decoded ) ;
305
309
assert . isNotNull ( err ) ;
306
310
assert . equal ( err . name , 'JsonWebTokenError' ) ;
307
311
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
312
+ done ( ) ;
308
313
} ) ;
309
314
} ) ;
310
315
} ) ;
311
316
312
317
describe ( 'when signing a token without subject' , function ( ) {
313
318
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' } ) ;
314
319
315
- it ( 'should check subject' , function ( ) {
320
+ it ( 'should check subject' , function ( done ) {
316
321
jwt . verify ( token , pub , { subject : 'subject' } , function ( err , decoded ) {
317
322
assert . isUndefined ( decoded ) ;
318
323
assert . isNotNull ( err ) ;
319
324
assert . equal ( err . name , 'JsonWebTokenError' ) ;
320
325
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
326
+ done ( ) ;
321
327
} ) ;
322
328
} ) ;
323
329
} ) ;
324
330
325
331
describe ( 'when signing a token with jwt id' , function ( ) {
326
332
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' , jwtid : 'jwtid' } ) ;
327
333
328
- it ( 'should check jwt id' , function ( ) {
334
+ it ( 'should check jwt id' , function ( done ) {
329
335
jwt . verify ( token , pub , { jwtid : 'jwtid' } , function ( err , decoded ) {
330
336
assert . isNotNull ( decoded ) ;
331
337
assert . isNull ( err ) ;
338
+ done ( ) ;
332
339
} ) ;
333
340
} ) ;
334
341
335
- it ( 'should throw when invalid jwt id' , function ( ) {
342
+ it ( 'should throw when invalid jwt id' , function ( done ) {
336
343
jwt . verify ( token , pub , { jwtid : 'wrongJwtid' } , function ( err , decoded ) {
337
344
assert . isUndefined ( decoded ) ;
338
345
assert . isNotNull ( err ) ;
339
346
assert . equal ( err . name , 'JsonWebTokenError' ) ;
340
347
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
348
+ done ( ) ;
341
349
} ) ;
342
350
} ) ;
343
351
} ) ;
344
352
345
353
describe ( 'when signing a token without jwt id' , function ( ) {
346
354
var token = jwt . sign ( { foo : 'bar' } , priv , { algorithm : 'RS256' } ) ;
347
355
348
- it ( 'should check jwt id' , function ( ) {
356
+ it ( 'should check jwt id' , function ( done ) {
349
357
jwt . verify ( token , pub , { jwtid : 'jwtid' } , function ( err , decoded ) {
350
358
assert . isUndefined ( decoded ) ;
351
359
assert . isNotNull ( err ) ;
352
360
assert . equal ( err . name , 'JsonWebTokenError' ) ;
353
361
assert . instanceOf ( err , jwt . JsonWebTokenError ) ;
362
+ done ( ) ;
354
363
} ) ;
355
364
} ) ;
356
365
} ) ;
0 commit comments