diff --git a/packages/worker/src/api/routes/global/tests/scim/users.spec.ts b/packages/worker/src/api/routes/global/tests/scim/users.spec.ts index f2188c2909..4d94a8d1c6 100644 --- a/packages/worker/src/api/routes/global/tests/scim/users.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim/users.spec.ts @@ -71,10 +71,6 @@ describe("/api/global/scim/v2/users", () => { await config.afterAll() }) - beforeEach(() => { - jest.clearAllMocks() - }) - const featureDisabledResponse = { error: { code: "feature_disabled", @@ -117,11 +113,41 @@ describe("/api/global/scim/v2/users", () => { }) }) }) + + describe("multiple users exist", () => { + const userCount = 30 + let users: ScimUserResponse[] + + beforeEach(async () => { + users = [] + + for (let i = 0; i < userCount; i++) { + const body = createScimCreateUserRequest() + users.push(await config.api.scimUsersAPI.post({ body })) + } + }) + + it("fetch full first page", async () => { + const response = await getScimUsers() + + expect(response).toEqual({ + Resources: expect.arrayContaining(users.splice(0, 20)), + itemsPerPage: 20, + schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"], + startIndex: 1, + totalResults: userCount, + }) + }) + }) }) describe("POST /api/global/scim/v2/users", () => { const postScimUser = config.api.scimUsersAPI.post + beforeAll(async () => { + await config.useNewTenant() + }) + it("unauthorised calls are not allowed", async () => { const response = await postScimUser( { body: {} as any }, diff --git a/packages/worker/src/tests/TestConfiguration.ts b/packages/worker/src/tests/TestConfiguration.ts index c1098729b1..5e606143f2 100644 --- a/packages/worker/src/tests/TestConfiguration.ts +++ b/packages/worker/src/tests/TestConfiguration.ts @@ -53,6 +53,12 @@ class TestConfiguration { this.api = new API(this) } + async useNewTenant() { + this.tenantId = structures.tenant.id() + + await this.beforeAll() + } + getRequest() { return this.request }