File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,41 @@ describe('OAuth2Strategy', function() {
51
51
} ) ;
52
52
} ) ; // that redirects to service provider
53
53
54
+ describe ( 'that redirects to service provider with other data in session' , function ( ) {
55
+ var request , url ;
56
+
57
+ before ( function ( done ) {
58
+ chai . passport . use ( strategy )
59
+ . redirect ( function ( u ) {
60
+ url = u ;
61
+ done ( ) ;
62
+ } )
63
+ . req ( function ( req ) {
64
+ request = req ;
65
+ req . session = { } ;
66
+ req . session [ 'oauth2:www.example.com' ] = { } ;
67
+ req . session [ 'oauth2:www.example.com' ] . foo = 'bar' ;
68
+ } )
69
+ . authenticate ( ) ;
70
+ } ) ;
71
+
72
+ it ( 'should be redirected' , function ( ) {
73
+ var u = uri . parse ( url , true ) ;
74
+ expect ( u . query . state ) . to . have . length ( 24 ) ;
75
+ } ) ;
76
+
77
+ it ( 'should save state in session' , function ( ) {
78
+ var u = uri . parse ( url , true ) ;
79
+
80
+ expect ( request . session [ 'oauth2:www.example.com' ] . state ) . to . have . length ( 24 ) ;
81
+ expect ( request . session [ 'oauth2:www.example.com' ] . state ) . to . equal ( u . query . state ) ;
82
+ } ) ;
83
+
84
+ it ( 'should preserve other data in session' , function ( ) {
85
+ expect ( request . session [ 'oauth2:www.example.com' ] . foo ) . to . equal ( 'bar' ) ;
86
+ } ) ;
87
+ } ) ; // that redirects to service provider with other data in session
88
+
54
89
describe ( 'that errors due to lack of session support in app' , function ( ) {
55
90
var request , err ;
56
91
You can’t perform that action at this time.
0 commit comments