|
@@ -62,7 +62,7 @@ describe('AwsS3Multipart', () => {
|
|
partNumber
|
|
partNumber
|
|
] = `https://bucket.s3.us-east-2.amazonaws.com/test/upload/multitest.dat?partNumber=${partNumber}&uploadId=6aeb1980f3fc7ce0b5454d25b71992&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIATEST%2F20210729%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20210729T014044Z&X-Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=test`
|
|
] = `https://bucket.s3.us-east-2.amazonaws.com/test/upload/multitest.dat?partNumber=${partNumber}&uploadId=6aeb1980f3fc7ce0b5454d25b71992&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIATEST%2F20210729%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20210729T014044Z&X-Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=test`
|
|
})
|
|
})
|
|
- return { presignedUrls }
|
|
|
|
|
|
+ return { presignedUrls, headers: { 1: { 'Content-MD5': 'foo' } } }
|
|
}),
|
|
}),
|
|
})
|
|
})
|
|
awsS3Multipart = core.getPlugin('AwsS3Multipart')
|
|
awsS3Multipart = core.getPlugin('AwsS3Multipart')
|
|
@@ -72,25 +72,32 @@ describe('AwsS3Multipart', () => {
|
|
const scope = nock(
|
|
const scope = nock(
|
|
'https://bucket.s3.us-east-2.amazonaws.com',
|
|
'https://bucket.s3.us-east-2.amazonaws.com',
|
|
).defaultReplyHeaders({
|
|
).defaultReplyHeaders({
|
|
|
|
+ 'access-control-allow-headers': '*',
|
|
'access-control-allow-method': 'PUT',
|
|
'access-control-allow-method': 'PUT',
|
|
'access-control-allow-origin': '*',
|
|
'access-control-allow-origin': '*',
|
|
- 'access-control-expose-headers': 'ETag',
|
|
|
|
|
|
+ 'access-control-expose-headers': 'ETag, Content-MD5',
|
|
})
|
|
})
|
|
// 6MB file will give us 2 chunks, so there will be 2 PUT and 2 OPTIONS
|
|
// 6MB file will give us 2 chunks, so there will be 2 PUT and 2 OPTIONS
|
|
// calls to the presigned URL from 1 prepareUploadParts calls
|
|
// calls to the presigned URL from 1 prepareUploadParts calls
|
|
const fileSize = 5 * MB + 1 * MB
|
|
const fileSize = 5 * MB + 1 * MB
|
|
|
|
|
|
scope
|
|
scope
|
|
- .options((uri) => uri.includes('test/upload/multitest.dat'))
|
|
|
|
- .reply(200, '')
|
|
|
|
|
|
+ .options((uri) => uri.includes('test/upload/multitest.dat?partNumber=1'))
|
|
|
|
+ .reply(function replyFn () {
|
|
|
|
+ expect(this.req.headers['access-control-request-headers']).toEqual('Content-MD5')
|
|
|
|
+ return [200, '']
|
|
|
|
+ })
|
|
scope
|
|
scope
|
|
- .options((uri) => uri.includes('test/upload/multitest.dat'))
|
|
|
|
- .reply(200, '')
|
|
|
|
|
|
+ .options((uri) => uri.includes('test/upload/multitest.dat?partNumber=2'))
|
|
|
|
+ .reply(function replyFn () {
|
|
|
|
+ expect(this.req.headers['access-control-request-headers']).toBeUndefined()
|
|
|
|
+ return [200, '']
|
|
|
|
+ })
|
|
scope
|
|
scope
|
|
- .put((uri) => uri.includes('test/upload/multitest.dat'))
|
|
|
|
|
|
+ .put((uri) => uri.includes('test/upload/multitest.dat?partNumber=1'))
|
|
.reply(200, '', { ETag: 'test1' })
|
|
.reply(200, '', { ETag: 'test1' })
|
|
scope
|
|
scope
|
|
- .put((uri) => uri.includes('test/upload/multitest.dat'))
|
|
|
|
|
|
+ .put((uri) => uri.includes('test/upload/multitest.dat?partNumber=2'))
|
|
.reply(200, '', { ETag: 'test2' })
|
|
.reply(200, '', { ETag: 'test2' })
|
|
|
|
|
|
core.addFile({
|
|
core.addFile({
|
|
@@ -115,6 +122,7 @@ describe('AwsS3Multipart', () => {
|
|
const scope = nock(
|
|
const scope = nock(
|
|
'https://bucket.s3.us-east-2.amazonaws.com',
|
|
'https://bucket.s3.us-east-2.amazonaws.com',
|
|
).defaultReplyHeaders({
|
|
).defaultReplyHeaders({
|
|
|
|
+ 'access-control-allow-headers': '*',
|
|
'access-control-allow-method': 'PUT',
|
|
'access-control-allow-method': 'PUT',
|
|
'access-control-allow-origin': '*',
|
|
'access-control-allow-origin': '*',
|
|
'access-control-expose-headers': 'ETag',
|
|
'access-control-expose-headers': 'ETag',
|
|
@@ -145,11 +153,12 @@ describe('AwsS3Multipart', () => {
|
|
|
|
|
|
await core.upload()
|
|
await core.upload()
|
|
|
|
|
|
- function validatePartData ({ partNumbers, chunks }, expected) {
|
|
|
|
- expect(partNumbers).toEqual(expected)
|
|
|
|
- partNumbers.forEach(partNumber => {
|
|
|
|
- expect(chunks[partNumber]).toBeDefined()
|
|
|
|
- })
|
|
|
|
|
|
+ function validatePartData ({ parts }, expected) {
|
|
|
|
+ expect(parts.map((part) => part.number)).toEqual(expected)
|
|
|
|
+
|
|
|
|
+ for (const part of parts) {
|
|
|
|
+ expect(part.chunk).toBeDefined()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
expect(awsS3Multipart.opts.prepareUploadParts.mock.calls.length).toEqual(3)
|
|
expect(awsS3Multipart.opts.prepareUploadParts.mock.calls.length).toEqual(3)
|