Test 403s

This commit is contained in:
adrinr 2023-03-10 12:07:18 +01:00
parent 7fef377e1d
commit 81e086680d
2 changed files with 26 additions and 16 deletions

View File

@ -1,12 +1,4 @@
import { InviteUsersResponse, User } from "@budibase/types"
jest.mock("nodemailer")
import { TestConfiguration, mocks, structures } from "../../../../../tests"
const sendMailMock = mocks.email.mock()
import { events, tenancy, accounts as _accounts } from "@budibase/backend-core"
import * as userSdk from "../../../../../sdk/users"
const accounts = jest.mocked(_accounts)
import { TestConfiguration } from "../../../../../tests"
describe("/api/global/scim/v2/users", () => {
const config = new TestConfiguration()
@ -24,6 +16,15 @@ describe("/api/global/scim/v2/users", () => {
})
describe("GET /api/global/scim/v2/users", () => {
it("unauthorised calls are not allowed", async () => {
const response = await config.api.scimUsersAPI.get({
setHeaders: false,
expect: 403,
})
expect(response).toEqual({ message: "Tenant id not set", status: 403 })
})
describe("no users exist", () => {
it("should retrieve empty list", async () => {
const response = await config.api.scimUsersAPI.get()
@ -40,8 +41,20 @@ describe("/api/global/scim/v2/users", () => {
})
describe("POST /api/global/scim/v2/users", () => {
it("unauthorised calls are not allowed", async () => {
const response = await config.api.scimUsersAPI.post(
{ body: {} as any },
{
setHeaders: false,
expect: 403,
}
)
expect(response).toEqual({ message: "Tenant id not set", status: 403 })
})
describe("no users exist", () => {
it("should retrieve empty list", async () => {
it("a new user can be created", async () => {
const body = {} as any
const response = await config.api.scimUsersAPI.post(body)

View File

@ -6,16 +6,13 @@ import {
import TestConfiguration from "../../TestConfiguration"
import { TestAPI } from "../base"
export interface RequestSettings {
expect: number
setHeaders: boolean
}
const defaultConfig: RequestSettings = {
const defaultConfig = {
expect: 200,
setHeaders: true,
}
type RequestSettings = typeof defaultConfig
export class ScimUsersAPI extends TestAPI {
constructor(config: TestConfiguration) {
super(config)