Merge pull request #16190 from overleaf/revert-15519-em-upgrade-passport
Revert "Upgrade passport" GitOrigin-RevId: 34a5442d6dae9623463908f92ab103bdc16f1b67
This commit is contained in:
@@ -77,7 +77,7 @@ describe('AuthenticationController', function () {
|
||||
'../User/UserSessionsManager': (this.UserSessionsManager = {
|
||||
trackSession: sinon.stub(),
|
||||
untrackSession: sinon.stub(),
|
||||
revokeAllUserSessions: sinon.stub().yields(null),
|
||||
revokeAllUserSessions: sinon.stub().callsArgWith(1, null),
|
||||
}),
|
||||
'../../infrastructure/Modules': (this.Modules = {
|
||||
hooks: { fire: sinon.stub().yields(null, []) },
|
||||
@@ -184,17 +184,17 @@ describe('AuthenticationController', function () {
|
||||
describe('passportLogin', function () {
|
||||
beforeEach(function () {
|
||||
this.info = null
|
||||
this.req.login = sinon.stub().yields(null)
|
||||
this.req.login = sinon.stub().callsArgWith(1, null)
|
||||
this.res.json = sinon.stub()
|
||||
this.req.session = {
|
||||
passport: { user: this.user },
|
||||
postLoginRedirect: '/path/to/redir/to',
|
||||
}
|
||||
this.req.session.destroy = sinon.stub().yields(null)
|
||||
this.req.session.save = sinon.stub().yields(null)
|
||||
this.req.session.destroy = sinon.stub().callsArgWith(0, null)
|
||||
this.req.session.save = sinon.stub().callsArgWith(0, null)
|
||||
this.req.sessionStore = { generate: sinon.stub() }
|
||||
this.AuthenticationController.finishLogin = sinon.stub()
|
||||
this.passport.authenticate.yields(null, this.user, this.info)
|
||||
this.passport.authenticate.callsArgWith(1, null, this.user, this.info)
|
||||
this.err = new Error('woops')
|
||||
})
|
||||
|
||||
@@ -205,7 +205,7 @@ describe('AuthenticationController', function () {
|
||||
|
||||
describe('when authenticate produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.passport.authenticate.yields(this.err)
|
||||
this.passport.authenticate.callsArgWith(1, this.err)
|
||||
})
|
||||
|
||||
it('should return next with an error', function () {
|
||||
@@ -221,7 +221,7 @@ describe('AuthenticationController', function () {
|
||||
describe('when authenticate produces a user', function () {
|
||||
beforeEach(function () {
|
||||
this.req.session.postLoginRedirect = 'some_redirect'
|
||||
this.passport.authenticate.yields(null, this.user, this.info)
|
||||
this.passport.authenticate.callsArgWith(1, null, this.user, this.info)
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
@@ -244,7 +244,7 @@ describe('AuthenticationController', function () {
|
||||
describe('when authenticate does not produce a user', function () {
|
||||
beforeEach(function () {
|
||||
this.info = { text: 'a', type: 'b' }
|
||||
this.passport.authenticate.yields(null, false, this.info)
|
||||
this.passport.authenticate.callsArgWith(1, null, false, this.info)
|
||||
})
|
||||
|
||||
it('should not call finishLogin', function () {
|
||||
@@ -273,7 +273,8 @@ describe('AuthenticationController', function () {
|
||||
beforeEach(function () {
|
||||
this.AuthenticationController._recordFailedLogin = sinon.stub()
|
||||
this.AuthenticationController._recordSuccessfulLogin = sinon.stub()
|
||||
this.Modules.hooks.fire = sinon.stub().yields(null, [])
|
||||
this.Modules.hooks.fire = sinon.stub().callsArgWith(3, null, [])
|
||||
// @AuthenticationController.establishUserSession = sinon.stub().callsArg(2)
|
||||
this.req.body = {
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
@@ -289,7 +290,7 @@ describe('AuthenticationController', function () {
|
||||
beforeEach(function () {
|
||||
this.Modules.hooks.fire = sinon
|
||||
.stub()
|
||||
.yields(null, [null, { redir: '/somewhere' }, null])
|
||||
.callsArgWith(3, null, [null, { redir: '/somewhere' }, null])
|
||||
})
|
||||
|
||||
it('should stop early and call done with this info object', function (done) {
|
||||
@@ -310,7 +311,7 @@ describe('AuthenticationController', function () {
|
||||
|
||||
describe('when the users rate limit', function () {
|
||||
beforeEach(function () {
|
||||
this.LoginRateLimiter.processLoginRequest.yields(null, false)
|
||||
this.LoginRateLimiter.processLoginRequest.callsArgWith(1, null, false)
|
||||
})
|
||||
|
||||
it('should block the request if the limit has been exceeded', function (done) {
|
||||
@@ -329,10 +330,10 @@ describe('AuthenticationController', function () {
|
||||
describe('when the user is authenticated', function () {
|
||||
beforeEach(function () {
|
||||
this.cb = sinon.stub()
|
||||
this.LoginRateLimiter.processLoginRequest.yields(null, true)
|
||||
this.LoginRateLimiter.processLoginRequest.callsArgWith(1, null, true)
|
||||
this.AuthenticationManager.authenticate = sinon
|
||||
.stub()
|
||||
.yields(null, this.user)
|
||||
.callsArgWith(3, null, this.user)
|
||||
this.req.sessionID = Math.random()
|
||||
})
|
||||
|
||||
@@ -360,7 +361,7 @@ describe('AuthenticationController', function () {
|
||||
beforeEach(function () {
|
||||
this.AuthenticationManager.authenticate = sinon
|
||||
.stub()
|
||||
.yields(new AuthenticationErrors.ParallelLoginError())
|
||||
.callsArgWith(3, new AuthenticationErrors.ParallelLoginError())
|
||||
this.AuthenticationController.doPassportLogin(
|
||||
this.req,
|
||||
this.req.body.email,
|
||||
@@ -436,10 +437,10 @@ describe('AuthenticationController', function () {
|
||||
|
||||
describe('when the user is not authenticated', function () {
|
||||
beforeEach(function () {
|
||||
this.LoginRateLimiter.processLoginRequest.yields(null, true)
|
||||
this.LoginRateLimiter.processLoginRequest.callsArgWith(1, null, true)
|
||||
this.AuthenticationManager.authenticate = sinon
|
||||
.stub()
|
||||
.yields(null, null)
|
||||
.callsArgWith(3, null, null)
|
||||
this.cb = sinon.stub()
|
||||
this.AuthenticationController.doPassportLogin(
|
||||
this.req,
|
||||
@@ -936,7 +937,7 @@ describe('AuthenticationController', function () {
|
||||
|
||||
describe('_recordSuccessfulLogin', function () {
|
||||
beforeEach(function () {
|
||||
this.UserUpdater.updateUser = sinon.stub().yields()
|
||||
this.UserUpdater.updateUser = sinon.stub().callsArg(2)
|
||||
this.AuthenticationController._recordSuccessfulLogin(
|
||||
this.user._id,
|
||||
this.callback
|
||||
@@ -1077,8 +1078,8 @@ describe('AuthenticationController', function () {
|
||||
this.req.session = {
|
||||
passport: { user: { _id: 'one' } },
|
||||
}
|
||||
this.req.session.destroy = sinon.stub().yields(null)
|
||||
this.req.session.save = sinon.stub().yields(null)
|
||||
this.req.session.destroy = sinon.stub().callsArgWith(0, null)
|
||||
this.req.session.save = sinon.stub().callsArgWith(0, null)
|
||||
this.req.sessionStore = { generate: sinon.stub() }
|
||||
this.req.login = sinon.stub().yields(null)
|
||||
|
||||
@@ -1344,7 +1345,9 @@ describe('AuthenticationController', function () {
|
||||
|
||||
describe('when req.session.save produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.req.session.save = sinon.stub().yields(new Error('woops'))
|
||||
this.req.session.save = sinon
|
||||
.stub()
|
||||
.callsArgWith(0, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function (done) {
|
||||
|
||||
@@ -173,7 +173,7 @@ describe('UserController', function () {
|
||||
describe('tryDeleteUser', function () {
|
||||
beforeEach(function () {
|
||||
this.req.body.password = 'wat'
|
||||
this.req.logout = sinon.stub().yields()
|
||||
this.req.logout = sinon.stub()
|
||||
this.req.session.destroy = sinon.stub().yields()
|
||||
this.SessionManager.getLoggedInUserId = sinon
|
||||
.stub()
|
||||
|
||||
Reference in New Issue
Block a user