@@ -159,7 +159,7 @@ describe('AuthorizeHandler integration', function() {
159
159
}
160
160
} ) ;
161
161
162
- it ( 'should throw an error if `allowed` is `false` ' , function ( ) {
162
+ it ( 'should redirect to an error response if user denied access ' , function ( ) {
163
163
const model = {
164
164
getAccessToken : function ( ) {
165
165
return {
@@ -170,49 +170,29 @@ describe('AuthorizeHandler integration', function() {
170
170
getClient : function ( ) {
171
171
return { grants : [ 'authorization_code' ] , redirectUris : [ 'http://example.com/cb' ] } ;
172
172
} ,
173
- saveAuthorizationCode : function ( ) {
174
- throw new Error ( 'Unhandled exception' ) ;
175
- }
173
+ saveAuthorizationCode : function ( ) { }
176
174
} ;
177
175
const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ;
178
176
const request = new Request ( {
179
177
body : {
180
- client_id : 'test'
178
+ client_id : 12345 ,
179
+ response_type : 'code'
181
180
} ,
181
+ method : { } ,
182
182
headers : {
183
183
'Authorization' : 'Bearer foo'
184
184
} ,
185
- method : { } ,
186
185
query : {
187
- allowed : 'false ' ,
188
- state : 'foobar '
186
+ state : 'foobar ' ,
187
+ allowed : 'false '
189
188
}
190
189
} ) ;
191
190
const response = new Response ( { body : { } , headers : { } } ) ;
192
191
193
192
return handler . handle ( request , response )
194
193
. 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' ) ;
216
196
} ) ;
217
197
} ) ;
218
198
0 commit comments