@@ -159,7 +159,7 @@ describe('AuthorizeHandler integration', function() {
159159 }
160160 } ) ;
161161
162- it ( 'should throw an error if `allowed` is `false` ' , function ( ) {
162+ it ( 'should redirect to an error response if user denied access ' , function ( ) {
163163 const model = {
164164 getAccessToken : function ( ) {
165165 return {
@@ -170,49 +170,29 @@ describe('AuthorizeHandler integration', function() {
170170 getClient : function ( ) {
171171 return { grants : [ 'authorization_code' ] , redirectUris : [ 'http://example.com/cb' ] } ;
172172 } ,
173- saveAuthorizationCode : function ( ) {
174- throw new Error ( 'Unhandled exception' ) ;
175- }
173+ saveAuthorizationCode : function ( ) { }
176174 } ;
177175 const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ;
178176 const request = new Request ( {
179177 body : {
180- client_id : 'test'
178+ client_id : 12345 ,
179+ response_type : 'code'
181180 } ,
181+ method : { } ,
182182 headers : {
183183 'Authorization' : 'Bearer foo'
184184 } ,
185- method : { } ,
186185 query : {
187- allowed : 'false ' ,
188- state : 'foobar '
186+ state : 'foobar ' ,
187+ allowed : 'false '
189188 }
190189 } ) ;
191190 const response = new Response ( { body : { } , headers : { } } ) ;
192191
193192 return handler . handle ( request , response )
194193 . then ( should . fail )
195- . catch ( function ( e ) {
196- e . should . be . an . instanceOf ( AccessDeniedError ) ;
197- e . message . should . equal ( 'Access denied: user denied access to application' ) ;
198- } ) ;
199- } ) ;
200-
201- it ( 'should throw an error if `allowed` is `false` body' , function ( ) {
202- const model = {
203- getAccessToken : function ( ) { } ,
204- getClient : function ( ) { } ,
205- saveAuthorizationCode : function ( ) { }
206- } ;
207- const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ;
208- const request = new Request ( { body : { allowed : 'false' } , headers : { } , method : { } , query : { } } ) ;
209- const response = new Response ( { body : { } , headers : { } } ) ;
210-
211- return handler . handle ( request , response )
212- . then ( should . fail )
213- . catch ( function ( e ) {
214- e . should . be . an . instanceOf ( AccessDeniedError ) ;
215- e . message . should . equal ( 'Access denied: user denied access to application' ) ;
194+ . catch ( function ( ) {
195+ response . get ( 'location' ) . should . equal ( 'http://example.com/cb?error=access_denied&error_description=Access%20denied%3A%20user%20denied%20access%20to%20application&state=foobar' ) ;
216196 } ) ;
217197 } ) ;
218198
0 commit comments