|
@@ -10,6 +10,7 @@ describe('UserAuditLogHandler', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.userId = new ObjectId()
|
|
this.userId = new ObjectId()
|
|
|
this.initiatorId = new ObjectId()
|
|
this.initiatorId = new ObjectId()
|
|
|
|
|
+ this.subscriptionId = new ObjectId()
|
|
|
this.action = {
|
|
this.action = {
|
|
|
operation: 'clear-sessions',
|
|
operation: 'clear-sessions',
|
|
|
initiatorId: this.initiatorId,
|
|
initiatorId: this.initiatorId,
|
|
@@ -24,9 +25,16 @@ describe('UserAuditLogHandler', function () {
|
|
|
ip: '0:0:0:0',
|
|
ip: '0:0:0:0',
|
|
|
}
|
|
}
|
|
|
this.UserAuditLogEntryMock = sinon.mock(UserAuditLogEntry)
|
|
this.UserAuditLogEntryMock = sinon.mock(UserAuditLogEntry)
|
|
|
|
|
+ this.getUniqueManagedSubscriptionMemberOfMock = sinon.stub().resolves()
|
|
|
this.UserAuditLogHandler = SandboxedModule.require(MODULE_PATH, {
|
|
this.UserAuditLogHandler = SandboxedModule.require(MODULE_PATH, {
|
|
|
requires: {
|
|
requires: {
|
|
|
'../../models/UserAuditLogEntry': { UserAuditLogEntry },
|
|
'../../models/UserAuditLogEntry': { UserAuditLogEntry },
|
|
|
|
|
+ '../Subscription/SubscriptionLocator': {
|
|
|
|
|
+ promises: {
|
|
|
|
|
+ getUniqueManagedSubscriptionMemberOf:
|
|
|
|
|
+ this.getUniqueManagedSubscriptionMemberOfMock,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -53,37 +61,33 @@ describe('UserAuditLogHandler', function () {
|
|
|
this.UserAuditLogEntryMock.verify()
|
|
this.UserAuditLogEntryMock.verify()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('updates the log for password reset operation witout a initiatorId', async function () {
|
|
|
|
|
- await expect(
|
|
|
|
|
- this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
- this.userId,
|
|
|
|
|
- 'reset-password',
|
|
|
|
|
- undefined,
|
|
|
|
|
- this.action.ip,
|
|
|
|
|
- this.action.info
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('updates the log for password reset operation without a initiatorId', async function () {
|
|
|
|
|
+ await this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ 'reset-password',
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ this.action.ip,
|
|
|
|
|
+ this.action.info
|
|
|
)
|
|
)
|
|
|
this.UserAuditLogEntryMock.verify()
|
|
this.UserAuditLogEntryMock.verify()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('updates the log for a email removal via script', async function () {
|
|
it('updates the log for a email removal via script', async function () {
|
|
|
- await expect(
|
|
|
|
|
- this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
- this.userId,
|
|
|
|
|
- 'remove-email',
|
|
|
|
|
- undefined,
|
|
|
|
|
- this.action.ip,
|
|
|
|
|
- {
|
|
|
|
|
- removedEmail: 'foo',
|
|
|
|
|
- script: true,
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ await this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ 'remove-email',
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ this.action.ip,
|
|
|
|
|
+ {
|
|
|
|
|
+ removedEmail: 'foo',
|
|
|
|
|
+ script: true,
|
|
|
|
|
+ }
|
|
|
)
|
|
)
|
|
|
this.UserAuditLogEntryMock.verify()
|
|
this.UserAuditLogEntryMock.verify()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('updates the log when no ip address or initiatorId is specified for a group join event', async function () {
|
|
it('updates the log when no ip address or initiatorId is specified for a group join event', async function () {
|
|
|
- this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
|
|
+ await this.UserAuditLogHandler.promises.addEntry(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
'join-group-subscription',
|
|
'join-group-subscription',
|
|
|
undefined,
|
|
undefined,
|
|
@@ -92,6 +96,31 @@ describe('UserAuditLogHandler', function () {
|
|
|
subscriptionId: 'foo',
|
|
subscriptionId: 'foo',
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
+ this.UserAuditLogEntryMock.verify()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('includes managedSubscriptionId for managed group user events ', async function () {
|
|
|
|
|
+ await this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ 'reset-password',
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ this.action.ip
|
|
|
|
|
+ )
|
|
|
|
|
+ this.UserAuditLogEntryMock.verify()
|
|
|
|
|
+ expect(this.getUniqueManagedSubscriptionMemberOfMock).to.have.been
|
|
|
|
|
+ .called
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('does not includes managedSubscriptionId for events not in the managed group event list', async function () {
|
|
|
|
|
+ await this.UserAuditLogHandler.promises.addEntry(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ 'foo',
|
|
|
|
|
+ this.action.initiatorId,
|
|
|
|
|
+ this.action.ip
|
|
|
|
|
+ )
|
|
|
|
|
+ this.UserAuditLogEntryMock.verify()
|
|
|
|
|
+ expect(this.getUniqueManagedSubscriptionMemberOfMock).not.to.have.been
|
|
|
|
|
+ .called
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|