File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,48 @@ describe('OAuth2Strategy', function() {
176
176
} ) ;
177
177
} ) ; // that was approved
178
178
179
+ describe ( 'that was approved with other data in the session' , function ( ) {
180
+ var request
181
+ , user
182
+ , info ;
183
+
184
+ before ( function ( done ) {
185
+ chai . passport . use ( strategy )
186
+ . success ( function ( u , i ) {
187
+ user = u ;
188
+ info = i ;
189
+ done ( ) ;
190
+ } )
191
+ . req ( function ( req ) {
192
+ request = req ;
193
+
194
+ req . query = { } ;
195
+ req . query . code = 'SplxlOBeZQQYbYS6WxSbIA' ;
196
+ req . query . state = 'DkbychwKu8kBaJoLE5yeR5NK' ;
197
+ req . session = { } ;
198
+ req . session [ 'oauth2:www.example.com' ] = { } ;
199
+ req . session [ 'oauth2:www.example.com' ] [ 'state' ] = 'DkbychwKu8kBaJoLE5yeR5NK' ;
200
+ req . session [ 'oauth2:www.example.com' ] . foo = 'bar' ;
201
+ } )
202
+ . authenticate ( ) ;
203
+ } ) ;
204
+
205
+ it ( 'should supply user' , function ( ) {
206
+ expect ( user ) . to . be . an . object ;
207
+ expect ( user . id ) . to . equal ( '1234' ) ;
208
+ } ) ;
209
+
210
+ it ( 'should supply info' , function ( ) {
211
+ expect ( info ) . to . be . an . object ;
212
+ expect ( info . message ) . to . equal ( 'Hello' ) ;
213
+ } ) ;
214
+
215
+ it ( 'should preserve other data from session' , function ( ) {
216
+ expect ( request . session [ 'oauth2:www.example.com' ] . state ) . to . be . undefined ;
217
+ expect ( request . session [ 'oauth2:www.example.com' ] . foo ) . to . equal ( 'bar' ) ;
218
+ } ) ;
219
+ } ) ; // that was approved with other data in the session
220
+
179
221
describe ( 'that fails due to state being invalid' , function ( ) {
180
222
var request
181
223
, info , status ;
You can’t perform that action at this time.
0 commit comments