Handle string boolean requests

This commit is contained in:
adrinr 2023-03-16 15:04:10 +01:00
parent 43c25436c8
commit d452f5cf0d
2 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,7 @@
import { ScimResource, ScimMeta, ScimPatchOperation } from "scim-patch"
type BooleanString = boolean | "True" | "False"
export interface ScimUserResponse extends ScimResource {
schemas: ["urn:ietf:params:scim:schemas:core:2.0:User"]
id: string
@ -13,7 +15,7 @@ export interface ScimUserResponse extends ScimResource {
familyName: string
givenName: string
}
active: boolean
active: BooleanString
emails: [
{
value: string
@ -30,7 +32,7 @@ export interface ScimCreateUserRequest {
]
externalId: string
userName: string
active: boolean
active: BooleanString
emails: [
{
primary: true

View File

@ -395,6 +395,24 @@ describe("/api/global/scim/v2/users", () => {
const persistedUser = await config.api.scimUsersAPI.find(user.id)
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" }],
}
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)
})
})
describe("DELETE /api/global/scim/v2/users/:id", () => {