Add tests
This commit is contained in:
parent
f8cebeba4e
commit
b120fce5dd
|
@ -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,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { AccountMetadata, ScimListResponse } from "@budibase/types"
|
||||
import {
|
||||
AccountMetadata,
|
||||
ScimListResponse,
|
||||
ScimUserRequest,
|
||||
} from "@budibase/types"
|
||||
import TestConfiguration from "../../TestConfiguration"
|
||||
import { TestAPI } from "../base"
|
||||
|
||||
|
@ -7,7 +11,7 @@ export class ScimUsersAPI extends TestAPI {
|
|||
super(config)
|
||||
}
|
||||
|
||||
get = async ({ expect }: { expect: number } = { expect: 200 }) => {
|
||||
get = async (expect = 200) => {
|
||||
const res = await this.request
|
||||
.get(`/api/global/scim/v2/users`)
|
||||
.set(this.config.bearerAPIHeaders())
|
||||
|
@ -16,4 +20,22 @@ export class ScimUsersAPI extends TestAPI {
|
|||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue