|
@@ -28,7 +28,7 @@ describe "AuthenticationController", ->
|
|
|
trackSession: sinon.stub()
|
|
trackSession: sinon.stub()
|
|
|
untrackSession: sinon.stub()
|
|
untrackSession: sinon.stub()
|
|
|
revokeAllUserSessions: sinon.stub().callsArgWith(1, null)
|
|
revokeAllUserSessions: sinon.stub().callsArgWith(1, null)
|
|
|
- "../../infrastructure/Modules": {hooks: {fire: sinon.stub().callsArgWith(2, null, [])}}
|
|
|
|
|
|
|
+ "../../infrastructure/Modules": @Modules = {hooks: {fire: sinon.stub().callsArgWith(2, null, [])}}
|
|
|
@user =
|
|
@user =
|
|
|
_id: ObjectId()
|
|
_id: ObjectId()
|
|
|
email: @email = "USER@example.com"
|
|
email: @email = "USER@example.com"
|
|
@@ -214,6 +214,7 @@ describe "AuthenticationController", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@AuthenticationController._recordFailedLogin = sinon.stub()
|
|
@AuthenticationController._recordFailedLogin = sinon.stub()
|
|
|
@AuthenticationController._recordSuccessfulLogin = sinon.stub()
|
|
@AuthenticationController._recordSuccessfulLogin = sinon.stub()
|
|
|
|
|
+ @Modules.hooks.fire = sinon.stub().callsArgWith(2, null, [])
|
|
|
# @AuthenticationController.establishUserSession = sinon.stub().callsArg(2)
|
|
# @AuthenticationController.establishUserSession = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
email: @email
|
|
email: @email
|
|
@@ -222,6 +223,17 @@ describe "AuthenticationController", ->
|
|
|
postLoginRedirect: "/path/to/redir/to"
|
|
postLoginRedirect: "/path/to/redir/to"
|
|
|
@cb = sinon.stub()
|
|
@cb = sinon.stub()
|
|
|
|
|
|
|
|
|
|
+ describe "when the preDoPassportLogin hooks produce an info object", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @Modules.hooks.fire = sinon.stub().callsArgWith(2, null, [null, {redir: '/somewhere'}, null])
|
|
|
|
|
+
|
|
|
|
|
+ it "should stop early and call done with this info object", (done) ->
|
|
|
|
|
+ @AuthenticationController.doPassportLogin(@req, @req.body.email, @req.body.password, @cb)
|
|
|
|
|
+ @cb.callCount.should.equal 1
|
|
|
|
|
+ @cb.calledWith(null, false, {redir: '/somewhere'}).should.equal true
|
|
|
|
|
+ @LoginRateLimiter.processLoginRequest.callCount.should.equal 0
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
describe "when the users rate limit", ->
|
|
describe "when the users rate limit", ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|