@@ -235,7 +235,7 @@ test('throw error if options are invalid – userInfo', (t) => {
235
235
} )
236
236
} )
237
237
238
- test ( 'throw no error if options are valid' , ( t ) => {
238
+ test ( 'throw no error if options are valid – secret ' , ( t ) => {
239
239
const valids = [
240
240
{ } ,
241
241
{ cache : { } } ,
@@ -251,11 +251,11 @@ test('throw no error if options are valid', (t) => {
251
251
valids . forEach ( ( valid ) => {
252
252
t . notThrows (
253
253
( ) => utils . verify ( helpers . getOptions ( valid ) ) ,
254
- Error , helpers . log ( 'valid' , valid ) )
254
+ Error , helpers . log ( 'valid.secret ' , valid ) )
255
255
} )
256
256
} )
257
257
258
- test ( 'throw no error if options are valid' , ( t ) => {
258
+ test ( 'throw no error if options are valid – publicKey/string ' , ( t ) => {
259
259
const valids = [
260
260
{ } ,
261
261
{ verifyOpts : undefined } ,
@@ -277,6 +277,58 @@ test('throw no error if options are valid', (t) => {
277
277
secret : undefined ,
278
278
publicKey : fixtures . common . publicKey
279
279
} , valid ) ) ) ,
280
- Error , helpers . log ( 'valid with publicKey' , valid ) )
280
+ Error , helpers . log ( 'valid.publicKey.string' , valid ) )
281
+ } )
282
+ } )
283
+
284
+ test ( 'throw no error if options are valid – publicKey/Buffer' , ( t ) => {
285
+ const valids = [
286
+ { } ,
287
+ { verifyOpts : undefined } ,
288
+ { verifyOpts : { } } ,
289
+ { verifyOpts : { audience : 'foobar' } } ,
290
+ { cache : { } } ,
291
+ { cache : { segment : 'foobar' } } ,
292
+ { cache : true } ,
293
+ { cache : false } ,
294
+ { userInfo : [ ] } ,
295
+ { userInfo : [ 'string' ] }
296
+ ]
297
+
298
+ t . plan ( valids . length )
299
+
300
+ valids . forEach ( ( valid ) => {
301
+ t . notThrows (
302
+ ( ) => utils . verify ( helpers . getOptions ( Object . assign ( {
303
+ secret : undefined ,
304
+ publicKey : fixtures . common . publicKeyBuffer
305
+ } , valid ) ) ) ,
306
+ Error , helpers . log ( 'valid.publicKey.Buffer' , valid ) )
307
+ } )
308
+ } )
309
+
310
+ test ( 'throw no error if options are valid – publicKey/Buffer/string' , ( t ) => {
311
+ const valids = [
312
+ { } ,
313
+ { verifyOpts : undefined } ,
314
+ { verifyOpts : { } } ,
315
+ { verifyOpts : { audience : 'foobar' } } ,
316
+ { cache : { } } ,
317
+ { cache : { segment : 'foobar' } } ,
318
+ { cache : true } ,
319
+ { cache : false } ,
320
+ { userInfo : [ ] } ,
321
+ { userInfo : [ 'string' ] }
322
+ ]
323
+
324
+ t . plan ( valids . length )
325
+
326
+ valids . forEach ( ( valid ) => {
327
+ t . notThrows (
328
+ ( ) => utils . verify ( helpers . getOptions ( Object . assign ( {
329
+ secret : undefined ,
330
+ publicKey : fixtures . common . publicKeyBuffer . toString ( )
331
+ } , valid ) ) ) ,
332
+ Error , helpers . log ( 'valid.publicKey.Buffer.string' , valid ) )
281
333
} )
282
334
} )
0 commit comments