Test extra cases

This commit is contained in:
adrinr 2023-03-16 15:16:36 +01:00
parent de716ba869
commit e222381a6c
2 changed files with 20 additions and 17 deletions

View File

@ -1,6 +1,6 @@
import { ScimResource, ScimMeta, ScimPatchOperation } from "scim-patch"
type BooleanString = boolean | "True" | "False"
type BooleanString = boolean | "True" | "true" | "False" | "false"
export interface ScimUserResponse extends ScimResource {
schemas: ["urn:ietf:params:scim:schemas:core:2.0:User"]

View File

@ -396,23 +396,26 @@ describe("/api/global/scim/v2/users", () => {
expect(persistedUser).toEqual(expectedScimUser)
})
it("can deactive an active user", async () => {
const body: ScimUpdateRequest = {
schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
Operations: [{ op: "Replace", path: "active", value: "False" }],
it.each([false, "false", "False"])(
"can deactive an active user (sending %s)",
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 })
const expectedScimUser: ScimUserResponse = {
...user,
active: false,
}
expect(response).toEqual(expectedScimUser)
const persistedUser = await config.api.scimUsersAPI.find(user.id)
expect(persistedUser).toEqual(expectedScimUser)
}
const response = await patchScimUser({ id: user.id, body })
const expectedScimUser: ScimUserResponse = {
...user,
active: false,
}
expect(response).toEqual(expectedScimUser)
const persistedUser = await config.api.scimUsersAPI.find(user.id)
expect(persistedUser).toEqual(expectedScimUser)
})
)
it("supports updating unmapped fields", async () => {
const body: ScimUpdateRequest = {