From 3ba3b18c2d91ee2382a398ce07f1a6f3b3a177eb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 3 Jul 2024 16:57:22 +0200 Subject: [PATCH] Add scim test --- .../src/api/routes/global/tests/scim.spec.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/worker/src/api/routes/global/tests/scim.spec.ts b/packages/worker/src/api/routes/global/tests/scim.spec.ts index 81dcc4b7c9..1b8039eac1 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -574,6 +574,38 @@ describe("scim", () => { expect(events.user.updated).toHaveBeenCalledTimes(1) }) + + it("an existing user's email can be updated", async () => { + const newEmail = structures.generator.email() + + const body: ScimUpdateRequest = { + schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], + Operations: [ + { + op: "Replace", + path: 'emails[type eq "work"].value', + value: newEmail, + }, + ], + } + + const response = await patchScimUser({ id: user.id, body }) + + const expectedScimUser: ScimUserResponse = { + ...user, + emails: [ + { + value: newEmail, + type: "work", + primary: true, + }, + ], + } + expect(response).toEqual(expectedScimUser) + + const persistedUser = await config.api.scimUsersAPI.find(user.id) + expect(persistedUser).toEqual(expectedScimUser) + }) }) describe("DELETE /api/global/scim/v2/users/:id", () => {