@@ -42,6 +42,7 @@ oauthshim.init({
42
42
app . all ( '/proxy' , oauthshim ) ;
43
43
44
44
45
+
45
46
////////////////////////////////
46
47
// SETUP REMOTE SERVER
47
48
// This reproduces a third party OAuth and API Server
@@ -82,6 +83,13 @@ remoteServer.use('/oauth/grant', function(req,res){
82
83
} ) ;
83
84
84
85
86
+ var error_unrecognised = {
87
+ error : {
88
+ code : 'invalid_request' ,
89
+ message : 'The request is unrecognised'
90
+ }
91
+ } ;
92
+
85
93
describe ( 'OAuth2 exchanging code for token,' , function ( ) {
86
94
87
95
var query = { } ;
@@ -318,7 +326,7 @@ describe('OAuth authenticate', function(){
318
326
for ( var x in o ) {
319
327
hash . push ( x + '=' + o [ x ] ) ;
320
328
}
321
- return new RegExp ( query . redirect_uri . replace ( / \/ / g, '\\/' ) + '#' + hash . join ( '&' ) ) ;
329
+ return new RegExp ( ( query . redirect_uri || '' ) . replace ( / \/ / g, '\\/' ) + '#' + hash . join ( '&' ) ) ;
322
330
}
323
331
324
332
@@ -411,6 +419,18 @@ describe('OAuth authenticate', function(){
411
419
} ) ;
412
420
} ) ;
413
421
422
+ it ( "should return error 'invalid_request' if redirect_uri is missing" , function ( done ) {
423
+
424
+ delete query . redirect_uri ;
425
+
426
+ request ( app )
427
+ . get ( '/proxy?' + querystring . stringify ( query ) )
428
+ . expect ( 200 , JSON . stringify ( error_unrecognised , null , 2 ) )
429
+ . end ( function ( err , res ) {
430
+ if ( err ) throw err ;
431
+ done ( ) ;
432
+ } ) ;
433
+ } ) ;
414
434
415
435
it ( "should error with required_credentials if the client_id was not provided" , function ( done ) {
416
436
0 commit comments