@@ -202,6 +202,24 @@ describe('features.ciba', () => {
202202 expect ( verifyUserCode [ 2 ] ) . to . equal ( '1234' ) ;
203203 } ) ;
204204
205+ it ( 'ignores client_notification_token when using poll' , async function ( ) {
206+ const [ , [ , request ] ] = await Promise . all ( [
207+ this . agent . post ( route )
208+ . send ( {
209+ scope : 'openid' ,
210+ login_hint : 'accountId' ,
211+ client_id : 'client' ,
212+ client_notification_token : 'foo bar' ,
213+ } )
214+ . type ( 'form' )
215+ . expect ( 200 )
216+ . expect ( 'content-type' , / a p p l i c a t i o n \/ j s o n / ) ,
217+ once ( emitter , 'triggerAuthenticationDevice' ) ,
218+ ] ) ;
219+
220+ expect ( request . params ) . not . to . have . property ( 'client_notification_token' ) ;
221+ } ) ;
222+
205223 it ( 'requested_expiry' , async function ( ) {
206224 await this . agent . post ( route )
207225 . send ( {
@@ -485,6 +503,62 @@ describe('features.ciba', () => {
485503 } ) ;
486504 } ) ;
487505
506+ it ( 'accepts the client_notification_token Bearer token syntax when using ping' , async function ( ) {
507+ return this . agent . post ( route )
508+ . send ( {
509+ client_id : 'client-ping' ,
510+ scope : 'openid' ,
511+ login_hint : 'accountId' ,
512+ client_notification_token : 'abc-._~+/==' ,
513+ } )
514+ . type ( 'form' )
515+ . expect ( 200 )
516+ . expect ( 'content-type' , / a p p l i c a t i o n \/ j s o n / ) ;
517+ } ) ;
518+
519+ it ( 'validates the client_notification_token syntax when using ping' , async function ( ) {
520+ const values = [
521+ 'foo bar' ,
522+ 'foo:bar' ,
523+ 'foo=bar' ,
524+ 'foo,bar' ,
525+ ] ;
526+
527+ for ( const client_notification_token of values ) {
528+ await this . agent . post ( route )
529+ . send ( {
530+ client_id : 'client-ping' ,
531+ scope : 'openid' ,
532+ login_hint : 'accountId' ,
533+ client_notification_token,
534+ } )
535+ . type ( 'form' )
536+ . expect ( 400 )
537+ . expect ( 'content-type' , / a p p l i c a t i o n \/ j s o n / )
538+ . expect ( {
539+ error : 'invalid_request' ,
540+ error_description : 'client_notification_token must be a valid Bearer token' ,
541+ } ) ;
542+ }
543+ } ) ;
544+
545+ it ( 'validates the client_notification_token length when using ping' , async function ( ) {
546+ return this . agent . post ( route )
547+ . send ( {
548+ client_id : 'client-ping' ,
549+ scope : 'openid' ,
550+ login_hint : 'accountId' ,
551+ client_notification_token : 'a' . repeat ( 1025 ) ,
552+ } )
553+ . type ( 'form' )
554+ . expect ( 400 )
555+ . expect ( 'content-type' , / a p p l i c a t i o n \/ j s o n / )
556+ . expect ( {
557+ error : 'invalid_request' ,
558+ error_description : 'client_notification_token must not exceed 1024 characters' ,
559+ } ) ;
560+ } ) ;
561+
488562 it ( 'requires the scope param with openid' , async function ( ) {
489563 const spy = sinon . spy ( ) ;
490564 this . provider . once ( 'backchannel_authentication.error' , spy ) ;
0 commit comments