Add tests

This commit is contained in:
Adria Navarro 2024-03-08 11:27:22 +01:00
parent 72e0388b62
commit d035f19b64
1 changed files with 43 additions and 0 deletions

View File

@ -780,6 +780,49 @@ describe("scim", () => {
)
})
})
it("creating an external group that conflicts an internal one syncs the existing group", async () => {
mocks.licenses.useGroups()
const groupToSave = structures.userGroups.userGroup()
const { body: internalGroup } = await config.api.groups.saveGroup(
groupToSave
)
const scimGroupData = {
externalId: structures.uuid(),
displayName: groupToSave.name,
}
const res = await postScimGroup(
{ body: structures.scim.createGroupRequest(scimGroupData) },
{ expect: 200 }
)
expect(res).toEqual(
expect.objectContaining({
id: internalGroup._id!,
externalId: scimGroupData.externalId,
displayName: scimGroupData.displayName,
})
)
})
it("a group cannot be SCIM synchronised with another SCIM group", async () => {
mocks.licenses.useGroups()
const groupToSave = structures.userGroups.userGroup()
const { body: internalGroup } = await config.api.groups.saveGroup(
groupToSave
)
const createGroupRequest = structures.scim.createGroupRequest({
displayName: groupToSave.name,
})
await postScimGroup({ body: createGroupRequest }, { expect: 200 })
await postScimGroup({ body: createGroupRequest }, { expect: 409 })
})
})
describe("GET /api/global/scim/v2/groups/:id", () => {