@@ -421,7 +421,7 @@ suite('sendNotification', function() {
421
421
} ) ;
422
422
} ) ;
423
423
424
- test ( 'invalid userPublicKey arguments ' , function ( ) {
424
+ test ( 'userPublicKey argument isn\'t a string ' , function ( ) {
425
425
return webPush . sendNotification ( 'https://127.0.0.1:' + serverPort , {
426
426
userPublicKey : userPublicKey ,
427
427
userAuth : urlBase64 . encode ( userAuth ) ,
@@ -434,7 +434,7 @@ suite('sendNotification', function() {
434
434
} ) ;
435
435
} ) ;
436
436
437
- test ( 'invalid userAuth arguments ' , function ( ) {
437
+ test ( 'userAuth argument isn\'t a string ' , function ( ) {
438
438
return webPush . sendNotification ( 'https://127.0.0.1:' + serverPort , {
439
439
userPublicKey : urlBase64 . encode ( userPublicKey ) ,
440
440
userAuth : userAuth ,
@@ -447,6 +447,45 @@ suite('sendNotification', function() {
447
447
} ) ;
448
448
} ) ;
449
449
450
+ test ( 'userPublicKey argument is too long' , function ( ) {
451
+ return webPush . sendNotification ( 'https://127.0.0.1:' + serverPort , {
452
+ userPublicKey : urlBase64 . encode ( Buffer . concat ( [ userPublicKey , new Buffer ( 1 ) ] ) ) ,
453
+ userAuth : urlBase64 . encode ( userAuth ) ,
454
+ payload : 'hello' ,
455
+ } )
456
+ . then ( function ( body ) {
457
+ assert ( false , 'sendNotification promise resolved' ) ;
458
+ } , function ( ) {
459
+ assert ( true , 'sendNotification promise rejected' ) ;
460
+ } ) ;
461
+ } ) ;
462
+
463
+ test ( 'userPublicKey argument is too short' , function ( ) {
464
+ return webPush . sendNotification ( 'https://127.0.0.1:' + serverPort , {
465
+ userPublicKey : urlBase64 . encode ( userPublicKey . slice ( 1 ) ) ,
466
+ userAuth : urlBase64 . encode ( userAuth ) ,
467
+ payload : 'hello' ,
468
+ } )
469
+ . then ( function ( body ) {
470
+ assert ( false , 'sendNotification promise resolved' ) ;
471
+ } , function ( ) {
472
+ assert ( true , 'sendNotification promise rejected' ) ;
473
+ } ) ;
474
+ } ) ;
475
+
476
+ test ( 'userAuth argument is too short' , function ( ) {
477
+ return webPush . sendNotification ( 'https://127.0.0.1:' + serverPort , {
478
+ userPublicKey : urlBase64 . encode ( userPublicKey ) ,
479
+ userAuth : urlBase64 . encode ( userAuth . slice ( 1 ) ) ,
480
+ payload : 'hello' ,
481
+ } )
482
+ . then ( function ( body ) {
483
+ assert ( false , 'sendNotification promise resolved' ) ;
484
+ } , function ( ) {
485
+ assert ( true , 'sendNotification promise rejected' ) ;
486
+ } ) ;
487
+ } ) ;
488
+
450
489
test ( 'TTL with old interface' , function ( ) {
451
490
return startServer ( undefined , 5 )
452
491
. then ( function ( ) {
0 commit comments