diff --git a/packages/worker/src/api/routes/global/tests/scim.spec.ts b/packages/worker/src/api/routes/global/tests/scim.spec.ts index 56b7ca9f40..ae0abadc5d 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -654,6 +654,26 @@ describe("scim", () => { totalResults: groupCount, }) }) + + it("can fetch groups even if internal groups exist", async () => { + mocks.licenses.useGroups() + await config.api.groups.saveGroup(structures.userGroups.userGroup()) + await config.api.groups.saveGroup(structures.userGroups.userGroup()) + + const response = await getScimGroups() + + expect(response).toEqual({ + Resources: expect.arrayContaining(groups), + itemsPerPage: 25, + schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"], + startIndex: 1, + totalResults: groupCount, + }) + + expect((await config.api.groups.fetch()).body.data).toHaveLength( + 25 + 2 // scim groups + internal groups + ) + }) }) }) diff --git a/packages/worker/src/tests/api/groups.ts b/packages/worker/src/tests/api/groups.ts index 91f7c92c7d..0b9081cc92 100644 --- a/packages/worker/src/tests/api/groups.ts +++ b/packages/worker/src/tests/api/groups.ts @@ -53,4 +53,12 @@ export class GroupsAPI extends TestAPI { .expect("Content-Type", /json/) .expect(200) } + + fetch = ({ expect } = { expect: 200 }) => { + return this.request + .get(`/api/global/groups`) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(expect) + } }