Merge pull request #3173 from overleaf/jel-institution-sso-audit-log

Update audit log when institution SSO is linked/unlinked

GitOrigin-RevId: 264ffbed025dccb4dd202f86afe545c3bf0c1f76
This commit is contained in:
Jessica Lawshe
2020-09-14 08:54:19 -05:00
committed by Copybot
parent 7c093ba115
commit aee83bc0cf
7 changed files with 446 additions and 173 deletions
@@ -66,11 +66,6 @@ describe('UserEmailsController', function() {
}
}),
'../Helpers/EmailHelper': this.EmailHelper,
'./UserAuditLogHandler': (this.UserAuditLogHandler = {
promises: {
addEntry: sinon.stub().resolves()
}
}),
'./UserEmailsConfirmationHandler': (this.UserEmailsConfirmationHandler = {
promises: {
sendConfirmationEmail: sinon.stub().resolves()
@@ -121,16 +116,14 @@ describe('UserEmailsController', function() {
.yields()
})
it('adds an entry to user audit log', function(done) {
it('passed audit log to addEmailAddress', function(done) {
this.res.sendStatus = sinon.stub()
this.res.sendStatus.callsFake(() => {
this.UserAuditLogHandler.promises.addEntry.should.have.been.calledWith(
this.user._id,
'add-email',
this.user._id,
this.req.ip,
{ newSecondaryEmail: this.newEmail }
)
const addCall = this.UserUpdater.promises.addEmailAddress.lastCall
expect(addCall.args[3]).to.deep.equal({
initiatorId: this.user._id,
ipAddress: this.req.ip
})
done()
})
this.UserEmailsController.add(this.req, this.res)
@@ -246,22 +239,6 @@ describe('UserEmailsController', function() {
})
this.UserEmailsController.add(this.req, this.res, this.next)
})
describe('errors', function() {
describe('via UserAuditLogHandler', function() {
beforeEach(function() {
this.UserAuditLogHandler.promises.addEntry.throws('oops')
})
it('should not add email and should return error', function(done) {
this.UserEmailsController.add(this.req, this.res, error => {
expect(error).to.exist
this.UserUpdater.promises.addEmailAddress.should.not.have.been
.called
done()
})
})
})
})
})
describe('remove', function() {