From cd202839b726fdb3e876c26c7c8d2aba1160014a Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 17 Mar 2023 18:47:34 +0100 Subject: [PATCH] Add multiple users tests --- .../routes/global/tests/scim/groups.spec.ts | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/worker/src/api/routes/global/tests/scim/groups.spec.ts b/packages/worker/src/api/routes/global/tests/scim/groups.spec.ts index 0f0706632a..7412eed832 100644 --- a/packages/worker/src/api/routes/global/tests/scim/groups.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim/groups.spec.ts @@ -312,7 +312,7 @@ describe("/api/global/scim/v2/groups", () => { }) describe("adding users", () => { - it("new users can be added to an existing group", async () => { + it("a new user can be added to an existing group", async () => { const userToAdd = _.sample(users)! const body: ScimUpdateRequest = { @@ -346,6 +346,48 @@ describe("/api/global/scim/v2/groups", () => { const persistedGroup = await config.api.scimGroupsAPI.find(group.id) expect(persistedGroup).toEqual(expectedScimGroup) }) + + it("multiple users can be added to an existing group", async () => { + const [user1ToAdd, user2ToAdd] = _.sampleSize(users, 2) + + const body: ScimUpdateRequest = { + schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], + Operations: [ + { + op: "Add", + path: "members", + value: [ + { + $ref: null, + value: user1ToAdd.id, + }, + { + $ref: null, + value: user2ToAdd.id, + }, + ], + }, + ], + } + + const response = await patchScimGroup({ id: group.id, body }) + + const expectedScimGroup: ScimGroupResponse = { + ...group, + members: expect.arrayContaining([ + { + value: user1ToAdd.id, + }, + { + value: user2ToAdd.id, + }, + ]), + } + expect(response).toEqual(expectedScimGroup) + + const persistedGroup = await config.api.scimGroupsAPI.find(group.id) + expect(persistedGroup).toEqual(expectedScimGroup) + }) }) }) })