1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Add tests

This commit is contained in:
adrinr 2023-03-10 11:19:22 +01:00
parent f8cebeba4e
commit b120fce5dd
2 changed files with 59 additions and 2 deletions

View file

@ -38,4 +38,39 @@ describe("/api/global/scim/v2/users", () => {
}) })
}) })
}) })
describe("POST /api/global/scim/v2/users", () => {
describe("no users exist", () => {
it("should retrieve empty list", async () => {
const body = {} as any
const response = await config.api.scimUsersAPI.post(body)
expect(response).toEqual({
schemas: ["urn:ietf:params:scim:schemas:core:2.0:User"],
id: "48af03ac28ad4fb88478",
externalId: "0a21f0f2-8d2a-4f8e-bf98-7363c4aed4ef",
meta: {
resourceType: "User",
created: "2018-03-27T19:59:26.000Z",
lastModified: "2018-03-27T19:59:26.000Z",
},
userName: "Test_User_ab6490ee-1e48-479e-a20b-2d77186b5dd1",
name: {
formatted: "givenName familyName",
familyName: "familyName",
givenName: "givenName",
},
active: true,
emails: [
{
value:
"Test_User_fd0ea19b-0777-472c-9f96-4f70d2226f2e@testuser.com",
type: "work",
primary: true,
},
],
})
})
})
})
}) })

View file

@ -1,4 +1,8 @@
import { AccountMetadata, ScimListResponse } from "@budibase/types" import {
AccountMetadata,
ScimListResponse,
ScimUserRequest,
} from "@budibase/types"
import TestConfiguration from "../../TestConfiguration" import TestConfiguration from "../../TestConfiguration"
import { TestAPI } from "../base" import { TestAPI } from "../base"
@ -7,7 +11,7 @@ export class ScimUsersAPI extends TestAPI {
super(config) super(config)
} }
get = async ({ expect }: { expect: number } = { expect: 200 }) => { get = async (expect = 200) => {
const res = await this.request const res = await this.request
.get(`/api/global/scim/v2/users`) .get(`/api/global/scim/v2/users`)
.set(this.config.bearerAPIHeaders()) .set(this.config.bearerAPIHeaders())
@ -16,4 +20,22 @@ export class ScimUsersAPI extends TestAPI {
return res.body as ScimListResponse return res.body as ScimListResponse
} }
post = async (
{
body,
}: {
body: ScimUserRequest
},
expect = 200
) => {
const res = await this.request
.post(`/api/global/scim/v2/users`)
.send(body)
.set(this.config.bearerAPIHeaders())
.expect("Content-Type", /json/)
.expect(expect)
return res.body as ScimListResponse
}
} }