Add scim tests
This commit is contained in:
parent
b2000c0805
commit
cd0004ec3d
|
@ -1 +1 @@
|
||||||
Subproject commit e565db07f6c51868087e88dfebde0328493443e6
|
Subproject commit 7accd0cb0b21258e9085568143dbf885f9f87afe
|
|
@ -103,6 +103,71 @@ describe("/api/global/groups", () => {
|
||||||
expect(events.group.updated).toBeCalledTimes(1)
|
expect(events.group.updated).toBeCalledTimes(1)
|
||||||
expect(events.group.permissionsEdited).not.toBeCalled()
|
expect(events.group.permissionsEdited).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("scim", () => {
|
||||||
|
async function createScimGroup() {
|
||||||
|
mocks.licenses.useScimIntegration()
|
||||||
|
await config.setSCIMConfig(true)
|
||||||
|
|
||||||
|
const scimGroup = await config.api.scimGroupsAPI.post({
|
||||||
|
body: structures.scim.createGroupRequest({
|
||||||
|
displayName: generator.word(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
const { body: group } = await config.api.groups.find(scimGroup.id)
|
||||||
|
|
||||||
|
expect(group).toBeDefined()
|
||||||
|
return group
|
||||||
|
}
|
||||||
|
|
||||||
|
it("update will not allow sending SCIM fields", async () => {
|
||||||
|
const group = await createScimGroup()
|
||||||
|
|
||||||
|
const updatedGroup: UserGroup = {
|
||||||
|
...group,
|
||||||
|
name: generator.word(),
|
||||||
|
}
|
||||||
|
await config.api.groups.saveGroup(updatedGroup, {
|
||||||
|
expect: {
|
||||||
|
message: 'Invalid body - "scimInfo" is not allowed',
|
||||||
|
status: 400,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(events.group.updated).not.toBeCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("update will not amend the SCIM fields", async () => {
|
||||||
|
const group: UserGroup = await createScimGroup()
|
||||||
|
|
||||||
|
const updatedGroup: UserGroup = {
|
||||||
|
...group,
|
||||||
|
name: generator.word(),
|
||||||
|
scimInfo: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
|
await config.api.groups.saveGroup(updatedGroup, {
|
||||||
|
expect: 200,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(events.group.updated).toBeCalledTimes(1)
|
||||||
|
expect(
|
||||||
|
(
|
||||||
|
await config.api.groups.find(group._id!, {
|
||||||
|
expect: 200,
|
||||||
|
})
|
||||||
|
).body
|
||||||
|
).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
...group,
|
||||||
|
name: updatedGroup.name,
|
||||||
|
scimInfo: group.scimInfo,
|
||||||
|
_rev: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("destroy", () => {
|
describe("destroy", () => {
|
||||||
|
|
|
@ -7,7 +7,10 @@ export class GroupsAPI extends TestAPI {
|
||||||
super(config)
|
super(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveGroup = (group: UserGroup, { expect } = { expect: 200 }) => {
|
saveGroup = (
|
||||||
|
group: UserGroup,
|
||||||
|
{ expect }: { expect: number | object } = { expect: 200 }
|
||||||
|
) => {
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/global/groups`)
|
.post(`/api/global/groups`)
|
||||||
.send(group)
|
.send(group)
|
||||||
|
@ -61,4 +64,12 @@ export class GroupsAPI extends TestAPI {
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(expect)
|
.expect(expect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find = (id: string, { expect } = { expect: 200 }) => {
|
||||||
|
return this.request
|
||||||
|
.get(`/api/global/groups/${id}`)
|
||||||
|
.set(this.config.defaultHeaders())
|
||||||
|
.expect("Content-Type", /json/)
|
||||||
|
.expect(expect)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue