From 122db55dcecccbc39b5ca36c1ce6cd28a5155dd3 Mon Sep 17 00:00:00 2001 From: adrinr Date: Mon, 10 Apr 2023 18:47:22 +0100 Subject: [PATCH] Fix tests --- .../src/api/routes/global/tests/scim.spec.ts | 46 +++---------------- packages/worker/src/tests/api/scim/shared.ts | 3 +- 2 files changed, 8 insertions(+), 41 deletions(-) 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 3dff3fb7a5..6c411a640d 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -399,53 +399,19 @@ describe("scim", () => { }) it.each([false, "false", "False"])( - "can deactive an active user (sending %s)", + "deactivating an active user (sending %s) will delete it", async activeValue => { const body: ScimUpdateRequest = { schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], Operations: [{ op: "Replace", path: "active", value: activeValue }], } - const response = await patchScimUser({ id: user.id, body }) + await patchScimUser( + { id: user.id, body }, + { expect: 204, skipContentTypeCheck: true } + ) - const expectedScimUser: ScimUserResponse = { - ...user, - active: false, - } - expect(response).toEqual(expectedScimUser) - - const persistedUser = await config.api.scimUsersAPI.find(user.id) - expect(persistedUser).toEqual(expectedScimUser) - } - ) - - it.each([true, "true", "True"])( - "can activate an inactive user (sending %s)", - async activeValue => { - // Deactivate user - await patchScimUser({ - id: user.id, - body: { - schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], - Operations: [{ op: "Replace", path: "active", value: true }], - }, - }) - - const body: ScimUpdateRequest = { - schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], - Operations: [{ op: "Replace", path: "active", value: activeValue }], - } - - const response = await patchScimUser({ id: user.id, body }) - - const expectedScimUser: ScimUserResponse = { - ...user, - active: true, - } - expect(response).toEqual(expectedScimUser) - - const persistedUser = await config.api.scimUsersAPI.find(user.id) - expect(persistedUser).toEqual(expectedScimUser) + await config.api.scimUsersAPI.find(user.id, { expect: 404 }) } ) diff --git a/packages/worker/src/tests/api/scim/shared.ts b/packages/worker/src/tests/api/scim/shared.ts index d99f4c20dc..1b064b8f41 100644 --- a/packages/worker/src/tests/api/scim/shared.ts +++ b/packages/worker/src/tests/api/scim/shared.ts @@ -4,6 +4,7 @@ import { TestAPI } from "../base" const defaultConfig = { expect: 200, setHeaders: true, + skipContentTypeCheck: false, } export type RequestSettings = typeof defaultConfig @@ -27,7 +28,7 @@ export abstract class ScimTestAPI extends TestAPI { "application/scim+json; charset=utf-8" ) - if (method !== "delete") { + if (method !== "delete" && !requestSettings?.skipContentTypeCheck) { request = request.expect("Content-Type", /json/) }