From c9a352bee78a7ea5239835a2364c257661b30531 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 27 May 2021 15:40:55 +0100 Subject: [PATCH] Fixing server test cases. --- packages/server/src/api/routes/tests/application.spec.js | 8 -------- packages/server/src/api/routes/tests/user.spec.js | 4 +++- packages/server/src/api/routes/tests/utilities/index.js | 5 +++++ packages/server/src/integrations/postgres.js | 4 ++-- packages/server/src/middleware/tests/currentapp.spec.js | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/routes/tests/application.spec.js b/packages/server/src/api/routes/tests/application.spec.js index dc550cd237..ac353ffb03 100644 --- a/packages/server/src/api/routes/tests/application.spec.js +++ b/packages/server/src/api/routes/tests/application.spec.js @@ -61,14 +61,6 @@ describe("/applications", () => { // two created apps + the inited app expect(res.body.length).toBe(3) }) - - it("should apply authorization to endpoint", async () => { - await checkBuilderEndpoint({ - config, - method: "GET", - url: `/api/applications`, - }) - }) }) describe("fetchAppDefinition", () => { diff --git a/packages/server/src/api/routes/tests/user.spec.js b/packages/server/src/api/routes/tests/user.spec.js index 129a5f44fa..30aa711524 100644 --- a/packages/server/src/api/routes/tests/user.spec.js +++ b/packages/server/src/api/routes/tests/user.spec.js @@ -1,13 +1,15 @@ const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") const { checkPermissionsEndpoint } = require("./utilities/TestFunctions") const setup = require("./utilities") -const { basicUser } = setup.structures const workerRequests = require("../../../utilities/workerRequests") jest.mock("../../../utilities/workerRequests", () => ({ getGlobalUsers: jest.fn(() => { return {} }), + getGlobalSelf: jest.fn(() => { + return {} + }), addAppRoleToUser: jest.fn(), deleteGlobalUser: jest.fn(), })) diff --git a/packages/server/src/api/routes/tests/utilities/index.js b/packages/server/src/api/routes/tests/utilities/index.js index 6a9f982bcb..713a3f799e 100644 --- a/packages/server/src/api/routes/tests/utilities/index.js +++ b/packages/server/src/api/routes/tests/utilities/index.js @@ -8,6 +8,11 @@ jest.mock("../../../../utilities/workerRequests", () => ({ _id: "us_uuid1", } }), + getGlobalSelf: jest.fn(() => { + return { + _id: "us_uuid1", + } + }), })) exports.delay = ms => new Promise(resolve => setTimeout(resolve, ms)) diff --git a/packages/server/src/integrations/postgres.js b/packages/server/src/integrations/postgres.js index 47790764a9..ed49e42f1c 100644 --- a/packages/server/src/integrations/postgres.js +++ b/packages/server/src/integrations/postgres.js @@ -58,9 +58,9 @@ const SCHEMA = { class PostgresIntegration { constructor(config) { this.config = config - if (this.config.ssl.rejectUnauthorized) { + if (this.config.ssl && this.config.ssl.rejectUnauthorized) { this.config.ssl.rejectUnauthorized = - this.config.ssl.rejectUnauthorized === "true" ? true : false + this.config.ssl.rejectUnauthorized === "true" } if (!pool) { diff --git a/packages/server/src/middleware/tests/currentapp.spec.js b/packages/server/src/middleware/tests/currentapp.spec.js index fd5a6623af..2b4a815542 100644 --- a/packages/server/src/middleware/tests/currentapp.spec.js +++ b/packages/server/src/middleware/tests/currentapp.spec.js @@ -3,7 +3,7 @@ mockWorker() function mockWorker() { jest.mock("../../utilities/workerRequests", () => ({ - getGlobalUsers: () => { + getGlobalSelf: () => { return { _id: "us_uuid1", roles: {