@@ -161,12 +161,33 @@ describe('AuthorizeHandler integration', function() {
161161
162162 it ( 'should throw an error if `allowed` is `false`' , function ( ) {
163163 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+ }
167176 } ;
168177 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+ } ) ;
170191 const response = new Response ( { body : { } , headers : { } } ) ;
171192
172193 return handler . handle ( request , response )
@@ -328,7 +349,7 @@ describe('AuthorizeHandler integration', function() {
328349 return handler . handle ( request , response )
329350 . then ( should . fail )
330351 . 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 ' ) ;
332353 } ) ;
333354 } ) ;
334355
@@ -416,7 +437,7 @@ describe('AuthorizeHandler integration', function() {
416437 return handler . handle ( request , response )
417438 . then ( should . fail )
418439 . 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 ' ) ;
420441 } ) ;
421442 } ) ;
422443
0 commit comments