Remove "duplicated" events
This commit is contained in:
parent
648247b10e
commit
62cd6a43f2
|
@ -22,4 +22,3 @@ export { default as plugin } from "./plugin"
|
||||||
export { default as backup } from "./backup"
|
export { default as backup } from "./backup"
|
||||||
export { default as environmentVariable } from "./environmentVariable"
|
export { default as environmentVariable } from "./environmentVariable"
|
||||||
export { default as auditLog } from "./auditLog"
|
export { default as auditLog } from "./auditLog"
|
||||||
export { default as scim } from "./scim"
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { publishEvent } from "../events"
|
|
||||||
import {
|
|
||||||
Event,
|
|
||||||
ScimUserDeletedEvent,
|
|
||||||
ScimUserUpdatedEvent,
|
|
||||||
} from "@budibase/types"
|
|
||||||
|
|
||||||
async function SCIMUserUpdated(props: {
|
|
||||||
userId: string
|
|
||||||
timestamp?: string | number
|
|
||||||
}) {
|
|
||||||
const properties: ScimUserUpdatedEvent = {
|
|
||||||
userId: props.userId,
|
|
||||||
}
|
|
||||||
await publishEvent(Event.SCIM_USER_UPDATED, properties, props.timestamp)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function SCIMUserDeleted(props: { userId: string }) {
|
|
||||||
const properties: ScimUserDeletedEvent = {
|
|
||||||
userId: props.userId,
|
|
||||||
}
|
|
||||||
await publishEvent(Event.SCIM_USER_DELETED, properties)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
SCIMUserUpdated,
|
|
||||||
SCIMUserDeleted,
|
|
||||||
}
|
|
|
@ -120,6 +120,3 @@ jest.spyOn(events.view, "calculationDeleted")
|
||||||
jest.spyOn(events.plugin, "init")
|
jest.spyOn(events.plugin, "init")
|
||||||
jest.spyOn(events.plugin, "imported")
|
jest.spyOn(events.plugin, "imported")
|
||||||
jest.spyOn(events.plugin, "deleted")
|
jest.spyOn(events.plugin, "deleted")
|
||||||
|
|
||||||
jest.spyOn(events.scim, "SCIMUserUpdated")
|
|
||||||
jest.spyOn(events.scim, "SCIMUserDeleted")
|
|
||||||
|
|
|
@ -184,10 +184,6 @@ export enum Event {
|
||||||
// AUDIT LOG
|
// AUDIT LOG
|
||||||
AUDIT_LOGS_FILTERED = "audit_log:filtered",
|
AUDIT_LOGS_FILTERED = "audit_log:filtered",
|
||||||
AUDIT_LOGS_DOWNLOADED = "audit_log:downloaded",
|
AUDIT_LOGS_DOWNLOADED = "audit_log:downloaded",
|
||||||
|
|
||||||
// SCIM
|
|
||||||
SCIM_USER_UPDATED = "scim:user:updated",
|
|
||||||
SCIM_USER_DELETED = "scim:user:deleted",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// all events that are not audited have been added to this record as undefined, this means
|
// all events that are not audited have been added to this record as undefined, this means
|
||||||
|
@ -368,10 +364,6 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
|
||||||
// AUDIT LOG - NOT AUDITED
|
// AUDIT LOG - NOT AUDITED
|
||||||
[Event.AUDIT_LOGS_FILTERED]: undefined,
|
[Event.AUDIT_LOGS_FILTERED]: undefined,
|
||||||
[Event.AUDIT_LOGS_DOWNLOADED]: undefined,
|
[Event.AUDIT_LOGS_DOWNLOADED]: undefined,
|
||||||
|
|
||||||
// SCIM
|
|
||||||
[Event.SCIM_USER_UPDATED]: `SCIM user "{{ email }}" updated`,
|
|
||||||
[Event.SCIM_USER_DELETED]: `SCIM user "{{ email }}" deleted`,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties added at the final stage of the event pipeline
|
// properties added at the final stage of the event pipeline
|
||||||
|
|
|
@ -241,18 +241,9 @@ describe("/api/global/scim/v2/users", () => {
|
||||||
it("an event is dispatched", async () => {
|
it("an event is dispatched", async () => {
|
||||||
const body = createScimCreateUserRequest()
|
const body = createScimCreateUserRequest()
|
||||||
|
|
||||||
const res = await postScimUser({ body })
|
await postScimUser({ body })
|
||||||
|
|
||||||
expect(events.user.created).toBeCalledTimes(1)
|
expect(events.user.created).toBeCalledTimes(1)
|
||||||
expect(events.user.created).toBeCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
_id: res.id,
|
|
||||||
createdAt: mockedTime.toISOString(),
|
|
||||||
scimInfo: expect.objectContaining({
|
|
||||||
isSync: true,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -456,11 +447,7 @@ describe("/api/global/scim/v2/users", () => {
|
||||||
|
|
||||||
await patchScimUser({ id: user.id, body })
|
await patchScimUser({ id: user.id, body })
|
||||||
|
|
||||||
expect(events.scim.SCIMUserUpdated).toBeCalledTimes(1)
|
expect(events.user.updated).toBeCalledTimes(1)
|
||||||
expect(events.scim.SCIMUserUpdated).toBeCalledWith({
|
|
||||||
userId: user.id,
|
|
||||||
timestamp: mockedTime.toISOString(),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -506,10 +493,7 @@ describe("/api/global/scim/v2/users", () => {
|
||||||
it("an event is dispatched", async () => {
|
it("an event is dispatched", async () => {
|
||||||
await deleteScimUser(user.id, { expect: 204 })
|
await deleteScimUser(user.id, { expect: 204 })
|
||||||
|
|
||||||
expect(events.scim.SCIMUserDeleted).toBeCalledTimes(1)
|
expect(events.user.deleted).toBeCalledTimes(1)
|
||||||
expect(events.scim.SCIMUserDeleted).toBeCalledWith({
|
|
||||||
userId: user.id,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue