Merge pull request #10310 from Budibase/budi-6855-allow-editing-group-display-names

BUDI-6855 - Allow editing group display names
This commit is contained in:
Adria Navarro 2023-04-17 10:51:41 +02:00 committed by GitHub
commit b5175884c7
2 changed files with 72 additions and 2 deletions

View File

@ -585,6 +585,59 @@ describe("scim", () => {
totalResults: groupCount,
})
})
it("can fetch groups using displayName filters", async () => {
const groupToFetch = _.sample(groups)
const response = await getScimGroups({
params: { filter: `displayName eq "${groupToFetch!.displayName}"` },
})
expect(response).toEqual({
Resources: [groupToFetch],
itemsPerPage: 1,
schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
startIndex: 1,
totalResults: 1,
})
})
it("can fetch groups excluding members", async () => {
const response = await getScimGroups({
params: { excludedAttributes: "members" },
})
expect(response).toEqual({
Resources: expect.arrayContaining(
groups.map(g => {
const { members, ...groupData } = g
return groupData
})
),
itemsPerPage: 25,
schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
startIndex: 1,
totalResults: groupCount,
})
})
it("can fetch groups excluding multiple fields", async () => {
const response = await getScimGroups({
params: { excludedAttributes: "members,displayName" },
})
expect(response).toEqual({
Resources: expect.arrayContaining(
groups.map(g => {
const { members, displayName, ...groupData } = g
return groupData
})
),
itemsPerPage: 25,
schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
startIndex: 1,
totalResults: groupCount,
})
})
})
})
@ -662,6 +715,16 @@ describe("scim", () => {
status: 404,
})
})
it("should allow excluding members", async () => {
const response = await findScimGroup(group.id, {
qs: "excludedAttributes=members",
})
const { members, ...expectedResponse } = group
expect(response).toEqual(expectedResponse)
})
})
describe("DELETE /api/global/scim/v2/groups/:id", () => {

View File

@ -18,6 +18,7 @@ export class ScimGroupsAPI extends ScimTestAPI {
startIndex?: number
pageSize?: number
filter?: string
excludedAttributes?: string
}
}
) => {
@ -32,6 +33,9 @@ export class ScimGroupsAPI extends ScimTestAPI {
if (params?.filter) {
url += `filter=${params.filter}&`
}
if (params?.excludedAttributes) {
url += `excludedAttributes=${params.excludedAttributes}&`
}
const res = await this.call(url, "get", requestSettings)
return res.body as ScimGroupListResponse
}
@ -54,9 +58,12 @@ export class ScimGroupsAPI extends ScimTestAPI {
return res.body as ScimGroupResponse
}
find = async (id: string, requestSettings?: Partial<RequestSettings>) => {
find = async (
id: string,
requestSettings?: Partial<RequestSettings> & { qs?: string }
) => {
const res = await this.call(
`/api/global/scim/v2/groups/${id}`,
`/api/global/scim/v2/groups/${id}?${requestSettings?.qs}`,
"get",
requestSettings
)