diff --git a/test/http/request.test.js b/test/http/request.test.js index 2337b147..8075faea 100644 --- a/test/http/request.test.js +++ b/test/http/request.test.js @@ -513,6 +513,35 @@ describe('http.ServerRequest', function() { }); }); + describe('establishing a session without session support', function() { + var passport = new Passport(); + passport.serializeUser(function(user, done) { + done(null, user.id); + }); + + var req = new Object(); + req.login = request.login; + req._passport = {}; + req._passport.instance = passport; + req._sessionManager = passport._sm; + + var error; + + before(function(done) { + var user = { id: '1', username: 'root' }; + + req.login(user, function(err) { + error = err; + done(); + }); + }); + + it('should error', function() { + expect(error).to.be.an.instanceOf(Error); + expect(error.message).to.equal('Login sessions require session support. Did you forget to use `express-session` middleware?'); + }); + }); + });