@@ -161,12 +161,33 @@ describe('AuthorizeHandler integration', function() {
161
161
162
162
it ( 'should throw an error if `allowed` is `false`' , function ( ) {
163
163
const model = {
164
- getAccessToken : function ( ) { } ,
165
- getClient : function ( ) { } ,
166
- saveAuthorizationCode : function ( ) { }
164
+ getAccessToken : function ( ) {
165
+ return {
166
+ user : { } ,
167
+ accessTokenExpiresAt : new Date ( new Date ( ) . getTime ( ) + 10000 )
168
+ } ;
169
+ } ,
170
+ getClient : function ( ) {
171
+ return { grants : [ 'authorization_code' ] , redirectUris : [ 'http://example.com/cb' ] } ;
172
+ } ,
173
+ saveAuthorizationCode : function ( ) {
174
+ throw new Error ( 'Unhandled exception' ) ;
175
+ }
167
176
} ;
168
177
const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ;
169
- const request = new Request ( { body : { } , headers : { } , method : { } , query : { allowed : 'false' } } ) ;
178
+ const request = new Request ( {
179
+ body : {
180
+ client_id : 'test'
181
+ } ,
182
+ headers : {
183
+ 'Authorization' : 'Bearer foo'
184
+ } ,
185
+ method : { } ,
186
+ query : {
187
+ allowed : 'false' ,
188
+ state : 'foobar'
189
+ }
190
+ } ) ;
170
191
const response = new Response ( { body : { } , headers : { } } ) ;
171
192
172
193
return handler . handle ( request , response )
@@ -328,7 +349,7 @@ describe('AuthorizeHandler integration', function() {
328
349
return handler . handle ( request , response )
329
350
. then ( should . fail )
330
351
. catch ( function ( ) {
331
- response . get ( 'location' ) . should . equal ( 'http://example.com/cb?error=invalid_scope&error_description=Invalid%20parameter%3A%20%60scope%60' ) ;
352
+ response . get ( 'location' ) . should . equal ( 'http://example.com/cb?error=invalid_scope&error_description=Invalid%20parameter%3A%20%60scope%60&state=foobar ' ) ;
332
353
} ) ;
333
354
} ) ;
334
355
@@ -416,7 +437,7 @@ describe('AuthorizeHandler integration', function() {
416
437
return handler . handle ( request , response )
417
438
. then ( should . fail )
418
439
. catch ( function ( ) {
419
- response . get ( 'location' ) . should . equal ( 'http://example.com/cb?error=invalid_scope&error_description=Invalid%20scope%3A%20Requested%20scope%20is%20invalid' ) ;
440
+ response . get ( 'location' ) . should . equal ( 'http://example.com/cb?error=invalid_scope&error_description=Invalid%20scope%3A%20Requested%20scope%20is%20invalid&state=foobar ' ) ;
420
441
} ) ;
421
442
} ) ;
422
443
0 commit comments