@@ -98,6 +98,55 @@ describe('middleware/authenticate', function() {
9898 expect ( request . account . username ) . to . equal ( 'jaredhanson' ) ;
9999 } ) ;
100100
101+ it ( 'should set authInfo to empty object' , function ( ) {
102+ expect ( request . authInfo ) . to . deep . equal ( { } ) ;
103+ } ) ;
104+ } ) ;
105+
106+ describe ( 'success that assigns a specific property with authInfo disabled' , function ( ) {
107+ function Strategy ( ) {
108+ }
109+ Strategy . prototype . authenticate = function ( req ) {
110+ var user = { id : '1' , username : 'jaredhanson' } ;
111+ this . success ( user ) ;
112+ } ;
113+
114+ var passport = new Passport ( ) ;
115+ passport . use ( 'success' , new Strategy ( ) ) ;
116+
117+ var request , error ;
118+
119+ before ( function ( done ) {
120+ chai . connect . use ( authenticate ( passport , 'success' , { assignProperty : 'account' , authInfo : false } ) )
121+ . req ( function ( req ) {
122+ request = req ;
123+
124+ req . logIn = function ( user , options , done ) {
125+ this . user = user ;
126+ done ( ) ;
127+ } ;
128+ } )
129+ . next ( function ( err ) {
130+ error = err ;
131+ done ( ) ;
132+ } )
133+ . dispatch ( ) ;
134+ } ) ;
135+
136+ it ( 'should not error' , function ( ) {
137+ expect ( error ) . to . be . undefined ;
138+ } ) ;
139+
140+ it ( 'should not set user' , function ( ) {
141+ expect ( request . user ) . to . be . undefined ;
142+ } ) ;
143+
144+ it ( 'should set account' , function ( ) {
145+ expect ( request . account ) . to . be . an ( 'object' ) ;
146+ expect ( request . account . id ) . to . equal ( '1' ) ;
147+ expect ( request . account . username ) . to . equal ( 'jaredhanson' ) ;
148+ } ) ;
149+
101150 it ( 'should not set authInfo' , function ( ) {
102151 expect ( request . authInfo ) . to . be . undefined ;
103152 } ) ;
0 commit comments