diff --git a/packages/worker/src/api/routes/global/tests/scim/users.spec.ts b/packages/worker/src/api/routes/global/tests/scim/users.spec.ts index 4321d56051..364aa7f450 100644 --- a/packages/worker/src/api/routes/global/tests/scim/users.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim/users.spec.ts @@ -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) diff --git a/packages/worker/src/tests/api/scim/users.ts b/packages/worker/src/tests/api/scim/users.ts index fd7f1b5fb2..4a1e995a96 100644 --- a/packages/worker/src/tests/api/scim/users.ts +++ b/packages/worker/src/tests/api/scim/users.ts @@ -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)