1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Use ids instead of email on the events

This commit is contained in:
adrinr 2023-03-24 14:34:40 +00:00
parent 26f077cc1c
commit 924c103ccc
3 changed files with 10 additions and 11 deletions

View file

@ -7,21 +7,21 @@ import {
} from "@budibase/types"
async function SCIMUserCreated(props: {
email: string
userId: string
timestamp?: string | number
}) {
const properties: ScimUserCreatedEvent = {
email: props.email,
userId: props.userId,
}
await publishEvent(Event.SCIM_USER_CREATED, properties, props.timestamp)
}
async function SCIMUserUpdated(props: {
email: string
userId: string
timestamp?: string | number
}) {
const properties: ScimUserUpdatedEvent = {
email: props.email,
userId: props.userId,
}
await publishEvent(Event.SCIM_USER_UPDATED, properties, props.timestamp)
}

View file

@ -1,11 +1,11 @@
import { BaseEvent } from "./event"
export interface ScimUserCreatedEvent extends BaseEvent {
email: string
userId: string
}
export interface ScimUserUpdatedEvent extends BaseEvent {
email: string
userId: string
}
export interface ScimUserDeletedEvent extends BaseEvent {
userId: string

View file

@ -239,14 +239,13 @@ describe("/api/global/scim/v2/users", () => {
})
it("an event is dispatched", async () => {
const email = structures.email()
const body = createScimCreateUserRequest({ email })
const body = createScimCreateUserRequest()
await postScimUser({ body })
const res = await postScimUser({ body })
expect(events.scim.SCIMUserCreated).toBeCalledTimes(1)
expect(events.scim.SCIMUserCreated).toBeCalledWith({
email,
userId: res.id,
timestamp: mockedTime.toISOString(),
})
})
@ -454,7 +453,7 @@ describe("/api/global/scim/v2/users", () => {
expect(events.scim.SCIMUserUpdated).toBeCalledTimes(1)
expect(events.scim.SCIMUserUpdated).toBeCalledWith({
email: user.emails[0].value,
userId: user.id,
timestamp: mockedTime.toISOString(),
})
})