Skip to content

Commit 9a1028c

Browse files
committed
Add unit test for an empty username accessing a restricted file
1 parent 6f009f9 commit 9a1028c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/authorizeRequest/authorizeRequest.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,15 @@ describe('authorizeRequest', () => {
201201
const result = await authorizeRequest(userRequest, null, testRanges);
202202
expect(result).toBe(true);
203203
});
204+
it('should return false if the request is for a restricted file and the userName is empty', async () => {
205+
const userRequest = {
206+
url: 'https://example-access-point.s3-object-lambda.us-east-1.amazonaws.com/somesite/files/__restricted/somegroup/somefile.json',
207+
headers: {
208+
Eppn: '',
209+
'X-Forwarded-Host': 'example.host.bu.edu, example.host.bu.edu',
210+
},
211+
};
212+
const result = await authorizeRequest(userRequest, null, testRanges);
213+
expect(result).toBe(false);
214+
});
204215
});

0 commit comments

Comments
 (0)