Skip to content

Commit

Permalink
add a test for item precedence over site rule
Browse files Browse the repository at this point in the history
where an item that is denied by the site rule but allowed by the individual protection should be allowed.
  • Loading branch information
jdub233 committed Nov 9, 2023
1 parent 2757bc8 commit ae2a208
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/authorizeRequest/authorizeRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,21 @@ describe('authorizeRequest', () => {
const result = await authorizeRequest(userRequest, siteRule);
expect(result).toBe(false);
});

it('should return true if the user is granted access by groupName even if denied by siteRule', async () => {
const userRequest = {
url: 'https://example-access-point.s3-object-lambda.us-east-1.amazonaws.com/somesite/files/2023/08/image.jpg',
headers: {
Eppn: '[email protected]', // This user should have access to 'somegroup' but not 'othergroup'.
'X-Real-Ip': '127.0.0.1',
'X-Forwarded-Host': 'example.host.bu.edu, example.host.bu.edu',
},
};
const siteRule = {
'example.host.bu.edu/somesite': 'othergroup',
};

const result = await authorizeRequest(userRequest, siteRule);
expect(result).toBe(true);
});
});

0 comments on commit ae2a208

Please sign in to comment.