Skip to content

Commit

Permalink
corrected test http status code for SampleAuthrozation and ProposalAu…
Browse files Browse the repository at this point in the history
…thorization
  • Loading branch information
Junjiequan committed Jul 22, 2024
1 parent cae8d10 commit 914b00b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 54 deletions.
42 changes: 38 additions & 4 deletions test/ProposalAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let proposalPid1 = null,
encodedProposalPid2 = null,
proposalPid3 = null,
encodedProposalPid3 = null;
// proposalPid10 = null,
// encodedProposalPid10 = null;

const proposal1 = {
...TestData.ProposalCorrectMin,
Expand All @@ -39,6 +41,14 @@ const proposal3 = {
accessGroups: ["group3"],
};

// const proposal10 = {
// ...TestData.ProposalCorrectMin,
// proposalId: "20170271",
// ownerGroup: "admin",
// accessGroups: ["admin"],
// isPublished: true,
// };

describe("1400: ProposalAuthorization: Test access to proposal", () => {
before(() => {
db.collection("Proposal").deleteMany({});
Expand Down Expand Up @@ -104,7 +114,7 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
done();
});

it("0010: adds proposal 1", async () => {
it("0000: adds proposal 1", async () => {
return request(appUrl)
.post("/api/v3/proposals")
.send(proposal1)
Expand All @@ -120,7 +130,7 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
});
});

it("0020: adds proposal 2", async () => {
it("0010: adds proposal 2", async () => {
return request(appUrl)
.post("/api/v3/proposals")
.send(proposal2)
Expand All @@ -136,7 +146,7 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
});
});

it("0030: adds proposal 3", async () => {
it("0020: adds proposal 3", async () => {
return request(appUrl)
.post("/api/v3/proposals")
.send(proposal3)
Expand All @@ -152,14 +162,38 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
});
});

// it("0030: adds proposal 10", async () => {
// return request(appUrl)
// .post("/api/v3/proposals")
// .send(proposal10)
// .set("Accept", "application/json")
// .set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
// .expect(TestData.EntryCreatedStatusCode)
// .expect("Content-Type", /json/)
// .then((res) => {
// res.body.should.have.property("ownerGroup").and.equal("admin");
// res.body.should.have.property("proposalId").and.be.string;
// proposalPid10 = res.body["proposalId"];
// encodedProposalPid10 = encodeURIComponent(proposalPid10);
// });
// });

it("0040: cannot access proposal as unauthenticated user", async () => {
return request(appUrl)
.get("/api/v3/proposals/" + encodedProposalPid2)
.set("Accept", "application/json")
.expect("Content-Type", /json/)
.expect(TestData.UnauthorizedStatusCode);
.expect(TestData.AccessForbiddenStatusCode);
});

// it("0045: can access public proposal as unauthenticated user", async () => {
// return request(appUrl)
// .get("/api/v3/proposals/" + encodedProposalPid10)
// .set("Accept", "application/json")
// .expect("Content-Type", /json/)
// .expect(TestData.SuccessfulGetStatusCode);
// });

it("0050: admin can list all proposals", async () => {
return request(appUrl)
.get("/api/v3/proposals")
Expand Down
Loading

0 comments on commit 914b00b

Please sign in to comment.