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

Net ID file set authorization for reading room #48

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/handlers/get-file-set-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function isAllowedVisibility(token, visibility, readingRoom) {
case "Public":
return true;
case "Institution":
return isValidToken(token);
return isValidToken(token) || readingRoom;
case "Private":
return readingRoom;
default:
Expand Down
15 changes: 15 additions & 0 deletions test/integration/get-file-set-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ describe("Authorize a file set by id", () => {
expect(result.statusCode).to.eq(403);
});

it("does authorize a netid, published file set with no token if the user is in the reading room", async () => {
mock
.get("/dc-v2-file-set/_doc/1234")
.reply(200, helpers.testFixture("mocks/fileset-netid-1234.json"));

const event = helpers
.mockEvent("GET", "/file-sets/{id}/authorization")
.pathParams({ id: 1234 })
.render();

process.env.READING_ROOM_IPS = event.requestContext.http.sourceIp;
const result = await handler(event);
expect(result.statusCode).to.eq(204);
});

it("authorizes an restricted file set if the user is in a Reading Room", async () => {
mock
.get("/dc-v2-file-set/_doc/1234")
Expand Down