Merge pull request #13216 from Budibase/BUDI-8046/sync-existing-groups

Add tests for matching SCIM groups
This commit is contained in:
Adria Navarro 2024-03-08 13:32:08 +01:00 committed by GitHub
commit a676ab2f7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 37 additions and 0 deletions

View File

@ -780,6 +780,43 @@ describe("scim", () => {
)
})
})
it("creating an external group that conflicts an internal one syncs the existing group", async () => {
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 () => {
const groupToSave = structures.userGroups.userGroup()
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", () => {