Merge pull request #11869 from overleaf/em-upgrade-mongoose-web

Upgrade Mongoose and the Mongo driver in web

GitOrigin-RevId: 2cad1aabe57eae424a9e4c68b2e0062f0e78ffaf
This commit is contained in:
Eric Mc Sween
2023-03-01 09:03:27 +00:00
committed by Copybot
parent 076bc9b39c
commit 65976cb363
43 changed files with 660 additions and 474 deletions
@@ -17,7 +17,7 @@ describe('AuthenticationManager', function () {
requires: {
'../../models/User': {
User: (this.User = {
updateOne: sinon.stub().callsArgWith(3, null, { nModified: 1 }),
updateOne: sinon.stub().callsArgWith(3, null, { modifiedCount: 1 }),
}),
},
'../../infrastructure/mongodb': {
@@ -99,7 +99,7 @@ describe('AuthenticationManager', function () {
})
it('should return the user', function () {
this.callback.calledWith(null, this.user).should.equal(true)
this.callback.should.have.been.calledWith(null, this.user)
})
it('should send metrics', function () {
@@ -147,7 +147,7 @@ describe('AuthenticationManager', function () {
beforeEach(function () {
this.User.updateOne = sinon
.stub()
.callsArgWith(3, null, { nModified: 0 })
.callsArgWith(3, null, { modifiedCount: 0 })
})
describe('correct password', function () {
@@ -171,7 +171,9 @@ describe('AuthenticationManager', function () {
describe('bad password', function () {
beforeEach(function (done) {
this.User.updateOne = sinon.stub().yields(null, { nModified: 0 })
this.User.updateOne = sinon
.stub()
.yields(null, { modifiedCount: 0 })
this.AuthenticationManager.authenticate(
{ email: this.email },
'notthecorrectpassword',
@@ -506,7 +506,7 @@ describe('CollaboratorsHandler', function () {
}
)
.chain('exec')
.resolves({ n: 1 })
.resolves({ matchedCount: 1 })
await this.CollaboratorsHandler.promises.setCollaboratorPrivilegeLevel(
this.projectId,
this.userId,
@@ -530,7 +530,7 @@ describe('CollaboratorsHandler', function () {
}
)
.chain('exec')
.resolves({ n: 1 })
.resolves({ matchedCount: 1 })
await this.CollaboratorsHandler.promises.setCollaboratorPrivilegeLevel(
this.projectId,
this.userId,
@@ -539,7 +539,9 @@ describe('CollaboratorsHandler', function () {
})
it('throws a NotFoundError if the project or collaborator does not exist', async function () {
this.ProjectMock.expects('updateOne').chain('exec').resolves({ n: 0 })
this.ProjectMock.expects('updateOne')
.chain('exec')
.resolves({ matchedCount: 0 })
await expect(
this.CollaboratorsHandler.promises.setCollaboratorPrivilegeLevel(
this.projectId,
@@ -75,7 +75,7 @@ describe('ProjectHistoryHandler', function () {
.callsArgWith(1, null, this.project)
this.ProjectModel.updateOne = sinon
.stub()
.callsArgWith(2, null, { n: 1 })
.callsArgWith(2, null, { matchedCount: 1 })
return this.ProjectHistoryHandler.ensureHistoryExistsForProject(
project_id,
this.callback
@@ -40,7 +40,7 @@ describe('UserAuditLogHandler', function () {
beforeEach(function () {
this.dbUpdate = this.UserAuditLogEntryMock.expects('create')
.chain('exec')
.resolves({ nModified: 1 })
.resolves({ modifiedCount: 1 })
})
it('writes a log', async function () {
await this.UserAuditLogHandler.promises.addEntry(
@@ -35,9 +35,11 @@ describe('UserCreator', function () {
}),
'./UserUpdater': (this.UserUpdater = {
promises: {
addAffiliationForNewUser: sinon
.stub()
.resolves({ n: 1, nModified: 1, ok: 1 }),
addAffiliationForNewUser: sinon.stub().resolves({
matchedCount: 1,
modifiedCount: 1,
acknowledged: true,
}),
updateUser: sinon.stub().resolves(),
},
}),