From 31d148e157d5f4595954497dd861a7282f977eba Mon Sep 17 00:00:00 2001 From: sofyalaski Date: Mon, 1 Jul 2024 11:05:04 +0200 Subject: [PATCH] empty collections before testing --- src/casl/casl-ability.factory.ts | 1 + test/Jobs.js | 7 ++++++- test/config/pretest.js | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/casl/casl-ability.factory.ts b/src/casl/casl-ability.factory.ts index 4702ffc6f..8f9b557a3 100644 --- a/src/casl/casl-ability.factory.ts +++ b/src/casl/casl-ability.factory.ts @@ -923,6 +923,7 @@ export class CaslAbilityFactory { ownerUser: user.username, }); + can(AuthOp.JobCreateConfiguration, JobClass, { ["configuration.create.auth" as string]: { $in: jobCreateInstanceAuthorizationValues, diff --git a/test/Jobs.js b/test/Jobs.js index 8848f9802..6fbbbed2b 100644 --- a/test/Jobs.js +++ b/test/Jobs.js @@ -221,6 +221,11 @@ describe("1100: Jobs: Test New Job Model", () => { ); }); + after(() => { //because we're not deleting all the jobs and don't delete datasets + db.collection("Dataset").deleteMany({}); + db.collection("Job").deleteMany({}); + }); + it("0010: adds dataset 1 as Admin Ingestor", async () => { return request(appUrl) .post("/api/v3/Datasets") @@ -520,7 +525,7 @@ describe("1100: Jobs: Test New Job Model", () => { }); }); - it("0130: AAdd a new job as a user from CREATE_JOB_GROUPS for another user in '#all' configuration, which should fail as bad request", async () => { + it("0130: Add a new job as a user from CREATE_JOB_GROUPS for another user in '#all' configuration, which should fail as bad request", async () => { const newDataset = { ...jobAll, ownerUser: "user5.1", diff --git a/test/config/pretest.js b/test/config/pretest.js index e884f4e73..011235be0 100644 --- a/test/config/pretest.js +++ b/test/config/pretest.js @@ -3,7 +3,7 @@ var chaiHttp = require("chai-http"); const { MongoClient } = require("mongodb"); -const uri = "mongodb://localhost:27017/scicat"; +const uri = process.env.MONGODB_URI; const client = new MongoClient(uri); @@ -16,4 +16,4 @@ loadChai(); global.appUrl = "http://localhost:3000"; global.request = require("supertest"); -global.db = client.db("scicat"); +global.db = client.db(uri.split("/", ).pop());