Fix tests

This commit is contained in:
adrinr 2023-04-10 18:47:22 +01:00
parent 6396548064
commit 122db55dce
2 changed files with 8 additions and 41 deletions

View File

@ -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 })
}
)

View File

@ -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/)
}