File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ OAuth2Server.prototype.authorise = function () {
67
67
var self = this ;
68
68
69
69
return function ( req , res , next ) {
70
- new Authorise ( self , req , next ) ;
70
+ return new Authorise ( self , req , next ) ;
71
71
} ;
72
72
} ;
73
73
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ var express = require('express'),
20
20
should = require ( 'should' ) ;
21
21
22
22
var oauth2server = require ( '../' ) ;
23
+ var Authorise = require ( '../lib/authorise' ) ;
23
24
24
25
var bootstrap = function ( oauthConfig ) {
25
26
var app = express ( ) ;
@@ -105,7 +106,24 @@ describe('Lockdown pattern', function() {
105
106
app . oauth . lockdown ( app ) ;
106
107
} ) ;
107
108
109
+ function mockRequest ( authoriseFactory ) {
110
+ var req = {
111
+ get : function ( ) { } ,
112
+ query : { access_token : { expires : null } }
113
+ } ;
114
+ var next = function ( ) { } ;
115
+
116
+ app . oauth . model . getAccessToken = function ( t , c ) { c ( null , t ) ; } ;
117
+
118
+ return authoriseFactory ( req , null , next ) ;
119
+ }
120
+
108
121
it ( 'adds authorise to non-bypassed routes' , function ( ) {
122
+ var authorise = mockRequest ( app . routes . get [ 0 ] . callbacks [ 0 ] ) ;
123
+ authorise . should . be . an . instanceOf ( Authorise ) ;
124
+ } ) ;
125
+
126
+ it ( 'runs non-bypassed routes after authorise' , function ( ) {
109
127
app . routes . get [ 0 ] . callbacks [ 1 ] . should . equal ( privateAction ) ;
110
128
} ) ;
111
129
You can’t perform that action at this time.
0 commit comments