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

View File

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

View File

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