Test adding user
This commit is contained in:
parent
9d0aff96e4
commit
76cb3e6061
|
@ -23,13 +23,6 @@ describe("/api/global/scim/v2/groups", () => {
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await config.beforeAll()
|
await config.beforeAll()
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
|
||||||
const body = structures.scim.createUserRequest()
|
|
||||||
users.push(await config.api.scimUsersAPI.post({ body }))
|
|
||||||
}
|
|
||||||
|
|
||||||
users = users.sort((a, b) => (a.id > b.id ? 1 : -1))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -156,6 +149,7 @@ describe("/api/global/scim/v2/groups", () => {
|
||||||
created: mockedTime.toISOString(),
|
created: mockedTime.toISOString(),
|
||||||
lastModified: mockedTime.toISOString(),
|
lastModified: mockedTime.toISOString(),
|
||||||
},
|
},
|
||||||
|
members: [],
|
||||||
}
|
}
|
||||||
expect(response).toEqual(expectedScimGroup)
|
expect(response).toEqual(expectedScimGroup)
|
||||||
|
|
||||||
|
@ -257,6 +251,17 @@ describe("/api/global/scim/v2/groups", () => {
|
||||||
const patchScimGroup = config.api.scimGroupsAPI.patch
|
const patchScimGroup = config.api.scimGroupsAPI.patch
|
||||||
|
|
||||||
let group: ScimGroupResponse
|
let group: ScimGroupResponse
|
||||||
|
let users: ScimUserResponse[]
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
users = []
|
||||||
|
for (let i = 0; i < 30; i++) {
|
||||||
|
const body = structures.scim.createUserRequest()
|
||||||
|
users.push(await config.api.scimUsersAPI.post({ body }))
|
||||||
|
}
|
||||||
|
|
||||||
|
users = users.sort((a, b) => (a.id > b.id ? 1 : -1))
|
||||||
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const body = structures.scim.createGroupRequest()
|
const body = structures.scim.createGroupRequest()
|
||||||
|
@ -305,5 +310,42 @@ describe("/api/global/scim/v2/groups", () => {
|
||||||
const persistedGroup = await config.api.scimGroupsAPI.find(group.id)
|
const persistedGroup = await config.api.scimGroupsAPI.find(group.id)
|
||||||
expect(persistedGroup).toEqual(expectedScimGroup)
|
expect(persistedGroup).toEqual(expectedScimGroup)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("adding users", () => {
|
||||||
|
it("new users can be added to an existing group", async () => {
|
||||||
|
const userToAdd = _.sample(users)!
|
||||||
|
|
||||||
|
const body: ScimUpdateRequest = {
|
||||||
|
schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
|
||||||
|
Operations: [
|
||||||
|
{
|
||||||
|
op: "Add",
|
||||||
|
path: "members",
|
||||||
|
value: [
|
||||||
|
{
|
||||||
|
$ref: null,
|
||||||
|
value: userToAdd.id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await patchScimGroup({ id: group.id, body })
|
||||||
|
|
||||||
|
const expectedScimGroup: ScimGroupResponse = {
|
||||||
|
...group,
|
||||||
|
members: [
|
||||||
|
{
|
||||||
|
value: userToAdd.id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
expect(response).toEqual(expectedScimGroup)
|
||||||
|
|
||||||
|
const persistedGroup = await config.api.scimGroupsAPI.find(group.id)
|
||||||
|
expect(persistedGroup).toEqual(expectedScimGroup)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue