mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #6255 from overleaf/jel-tidy-saml-tests
[web] Tidy SAML tests GitOrigin-RevId: 3b13fa847d935235bafe61c4118b046eb972f922
This commit is contained in:
@@ -339,39 +339,38 @@ describe('SAMLIdentityManager', function () {
|
|||||||
this.UserGetter.promises.getUser.onSecondCall().resolves(this.user)
|
this.UserGetter.promises.getUser.onSecondCall().resolves(this.user)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update the user audit log', function () {
|
it('should update the user audit log', async function () {
|
||||||
const auditLog = {
|
const auditLog = {
|
||||||
intiatorId: '6005c75b12cbcaf771f4a105',
|
initiatorId: '6005c75b12cbcaf771f4a105',
|
||||||
ip: '0:0:0:0',
|
ipAddress: '0:0:0:0',
|
||||||
}
|
}
|
||||||
this.SAMLIdentityManager.linkAccounts(
|
await this.SAMLIdentityManager.linkAccounts(
|
||||||
this.user._id,
|
this.user._id,
|
||||||
'externalUserId',
|
'externalUserId',
|
||||||
this.user.email,
|
this.user.email,
|
||||||
'1',
|
'1',
|
||||||
'Overleaf University',
|
'Overleaf University',
|
||||||
undefined,
|
undefined,
|
||||||
auditLog,
|
auditLog
|
||||||
() => {
|
)
|
||||||
expect(
|
|
||||||
this.UserAuditLogHandler.promises.addEntry
|
expect(
|
||||||
).to.have.been.calledWith(
|
this.UserAuditLogHandler.promises.addEntry
|
||||||
this.user._id,
|
).to.have.been.calledWith(
|
||||||
'link-institution-sso',
|
this.user._id,
|
||||||
auditLog.initiatorId,
|
'link-institution-sso',
|
||||||
auditLog.ip,
|
auditLog.initiatorId,
|
||||||
{
|
auditLog.ipAddress,
|
||||||
institutionEmail: this.user.email,
|
{
|
||||||
providerId: '1',
|
institutionEmail: this.user.email,
|
||||||
providerName: 'Overleaf University',
|
providerId: '1',
|
||||||
}
|
providerName: 'Overleaf University',
|
||||||
)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should send an email notification', function () {
|
it('should send an email notification', async function () {
|
||||||
this.SAMLIdentityManager.linkAccounts(
|
await this.SAMLIdentityManager.linkAccounts(
|
||||||
this.user._id,
|
this.user._id,
|
||||||
'externalUserId',
|
'externalUserId',
|
||||||
this.user.email,
|
this.user.email,
|
||||||
@@ -381,18 +380,17 @@ describe('SAMLIdentityManager', function () {
|
|||||||
{
|
{
|
||||||
intiatorId: '6005c75b12cbcaf771f4a105',
|
intiatorId: '6005c75b12cbcaf771f4a105',
|
||||||
ipAddress: '0:0:0:0',
|
ipAddress: '0:0:0:0',
|
||||||
},
|
|
||||||
() => {
|
|
||||||
expect(this.User.updateOne).to.have.been.called
|
|
||||||
expect(this.EmailHandler.sendEmail).to.have.been.calledOnce
|
|
||||||
const emailArgs = this.EmailHandler.sendEmail.lastCall.args
|
|
||||||
expect(emailArgs[0]).to.equal('securityAlert')
|
|
||||||
expect(emailArgs[1].to).to.equal(this.user.email)
|
|
||||||
expect(emailArgs[1].actionDescribed).to.contain('was linked')
|
|
||||||
expect(emailArgs[1].message[0]).to.contain('Linked')
|
|
||||||
expect(emailArgs[1].message[0]).to.contain(this.user.email)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
expect(this.User.findOneAndUpdate).to.have.been.called
|
||||||
|
expect(this.EmailHandler.sendEmail).to.have.been.calledOnce
|
||||||
|
const emailArgs = this.EmailHandler.sendEmail.lastCall.args
|
||||||
|
expect(emailArgs[0]).to.equal('securityAlert')
|
||||||
|
expect(emailArgs[1].to).to.equal(this.user.email)
|
||||||
|
expect(emailArgs[1].actionDescribed).to.contain('was linked')
|
||||||
|
expect(emailArgs[1].message[0]).to.contain('Linked')
|
||||||
|
expect(emailArgs[1].message[0]).to.contain(this.user.email)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user