Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove nested structure in tests authorization #1350

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 12 additions & 23 deletions test/DatasetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,23 @@ var pidRaw2 = null;
var policyIds = null;
const raw2 = { ...TestData.RawCorrect };

describe("0500: DatasetLifecycle: Test facet and filter queries", () => {
describe.only("0500: DatasetLifecycle: Test facet and filter queries", () => {
Junjiequan marked this conversation as resolved.
Show resolved Hide resolved
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
34 changes: 11 additions & 23 deletions test/DerivedDatasetDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,20 @@ describe("0750: DerivedDatasetDatablock: Test Datablocks and their relation to d

let datablockId1 = null;
let datablockId2 = null;

beforeEach((done) => {
beforeEach(async() => {
before(() => {
db.collection("Dataset").deleteMany({});
});
sofyalaski marked this conversation as resolved.
Show resolved Hide resolved
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();
},
);
},
);
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("0100:adds a new derived dataset", async () => {
Expand Down
Loading