Add multiple users tests

This commit is contained in:
adrinr 2023-03-17 18:47:34 +01:00
parent 76cb3e6061
commit cd202839b7
1 changed files with 43 additions and 1 deletions

View File

@ -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)
})
})
})
})