Skip to content

Commit

Permalink
Add test for S3 region rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Jul 28, 2023
1 parent 5c0609c commit 7e65e0d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/unit/s3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@ describeIf('S3', () => {
// Image doesnt exist in S3
expect(imageNotExist).toBeNull()
})

test('Test whether the wrong region was set', async () => {
const wrongS3UrlObj = urlParser.parse('https://wrong-s3.region.com/?keyId=123&secretAccessKey=123&bucketName=kiwix', true)

expect(
() =>
new S3(`${wrongS3UrlObj.protocol}//${wrongS3UrlObj.host}/`, {
bucketName: wrongS3UrlObj.query.bucketName,
keyId: wrongS3UrlObj.query.keyId,
secretAccessKey: wrongS3UrlObj.query.secretAccessKey,
}),
).toThrow('Unknown S3 region set')
})
})

0 comments on commit 7e65e0d

Please sign in to comment.