Skip to content

Commit

Permalink
remove nested structure in tests authorization (#1350)
Browse files Browse the repository at this point in the history
* remove nested structure in tests authorization

* remove a mistake

* fix requested changes

* fix indent
  • Loading branch information
sofyalaski authored Jul 30, 2024
1 parent d42f8c4 commit 9153eeb
Show file tree
Hide file tree
Showing 26 changed files with 503 additions and 936 deletions.
97 changes: 32 additions & 65 deletions test/DatasetAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,71 +45,38 @@ describe("0300: DatasetAuthorization: Test access to dataset", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "user1",
password: TestData.Accounts["user1"]["password"],
},
(tokenVal) => {
accessTokenUser1 = tokenVal;
utils.getToken(
appUrl,
{
username: "user2",
password: TestData.Accounts["user2"]["password"],
},
(tokenVal) => {
accessTokenUser2 = tokenVal;
utils.getToken(
appUrl,
{
username: "user3",
password: TestData.Accounts["user3"]["password"],
},
(tokenVal) => {
accessTokenUser3 = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password:
TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
utils.getToken(
appUrl,
{
username: "admin",
password: TestData.Accounts["admin"]["password"],
},
(tokenVal) => {
accessTokenAdmin = tokenVal;
done();
},
);
},
);
},
);
},
);
},
);
},
);
});

beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

accessTokenUser1 = await utils.getToken(appUrl, {
username: "user1",
password: TestData.Accounts["user1"]["password"],
});

accessTokenUser2 = await utils.getToken(appUrl, {
username: "user2",
password: TestData.Accounts["user2"]["password"],
});

accessTokenUser3 = await utils.getToken(appUrl, {
username: "user3",
password: TestData.Accounts["user3"]["password"],
});

accessTokenAdmin = await utils.getToken(appUrl, {
username: "admin",
password: TestData.Accounts["admin"]["password"],
});

accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
});

afterEach((done) => {
sandbox.restore();
done();
Expand Down
78 changes: 25 additions & 53 deletions test/DatasetFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,59 +96,31 @@ describe("0400: DatasetFilter: Test retrieving datasets using filtering capabili
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "user1",
password: TestData.Accounts["user1"]["password"],
},
(tokenVal) => {
accessTokenUser1 = tokenVal;
utils.getToken(
appUrl,
{
username: "user2",
password: TestData.Accounts["user2"]["password"],
},
(tokenVal) => {
accessTokenUser2 = tokenVal;
utils.getToken(
appUrl,
{
username: "user3",
password: TestData.Accounts["user2"]["password"],
},
(tokenVal) => {
accessTokenUser3 = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password:
TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
},
);
},
);
},
);
},
);
},
);
beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

accessTokenUser1 = await utils.getToken(appUrl, {
username: "user1",
password: TestData.Accounts["user1"]["password"],
});

accessTokenUser2 = await utils.getToken(appUrl, {
username: "user2",
password: TestData.Accounts["user2"]["password"],
});

accessTokenUser3 = await utils.getToken(appUrl, {
username: "user3",
password: TestData.Accounts["user3"]["password"],
});

accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
});

afterEach((done) => {
Expand Down
33 changes: 11 additions & 22 deletions test/DatasetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,19 @@ describe("0500: DatasetLifecycle: Test facet and filter queries", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
},
);
},
);
beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
});


it("0010: adds a new raw dataset", async () => {
return request(appUrl)
.post("/api/v3/Datasets")
Expand Down
32 changes: 10 additions & 22 deletions test/DatasetSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,16 @@ describe("0200: Dataset Simple: Check different dataset types and their inherita
db.collection("Dataset").deleteMany({});
});

beforeEach((done) => {
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
},
);
},
);
beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
});

function deleteDataset(item) {
Expand Down
62 changes: 20 additions & 42 deletions test/DerivedDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,26 @@ describe("0700: DerivedDataset: Derived Datasets", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "user1",
password: TestData.Accounts["user1"]["password"],
},
(tokenVal) => {
accessTokenUser1 = tokenVal;
utils.getToken(
appUrl,
{
username: "user2",
password: TestData.Accounts["user2"]["password"],
},
(tokenVal) => {
accessTokenUser2 = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
},
);
},
);
},
);
},
);
beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

accessTokenUser1 = await utils.getToken(appUrl, {
username: "user1",
password: TestData.Accounts["user1"]["password"],
});

accessTokenUser2 = await utils.getToken(appUrl, {
username: "user2",
password: TestData.Accounts["user2"]["password"],
});

accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
});

async function deleteDataset(item) {
Expand Down
35 changes: 11 additions & 24 deletions test/DerivedDatasetDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,19 @@ describe("0750: DerivedDatasetDatablock: Test Datablocks and their relation to d

let datablockId1 = null;
let datablockId2 = null;
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach(async() => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
});

beforeEach((done) => {
before(() => {
db.collection("Dataset").deleteMany({});
accessTokenArchiveManager = await utils.getToken(appUrl, {
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
});
utils.getToken(
appUrl,
{
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor = tokenVal;
utils.getToken(
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
},
);
},
);
});

it("0100:adds a new derived dataset", async () => {
Expand Down
Loading

0 comments on commit 9153eeb

Please sign in to comment.