@@ -61,30 +61,28 @@ describe('Object Part Copy', () => {
6161 process . stdout . write ( `Error creating source bucket: ${ err } \n` ) ;
6262 throw err ;
6363 } ) . then ( ( ) =>
64- { return s3 . createBucketPromise ( { Bucket : destBucketName } ) }
64+ s3 . createBucketPromise ( { Bucket : destBucketName } )
6565 ) . catch ( err => {
6666 process . stdout . write ( `Error creating dest bucket: ${ err } \n` ) ;
6767 throw err ;
6868 } )
69- . then ( ( ) => {
70- return s3 . send ( new PutObjectCommand ( {
69+ . then ( ( ) => s3 . send ( new PutObjectCommand ( {
7170 Bucket : sourceBucketName ,
7271 Key : sourceObjName ,
7372 Body : content ,
74- } ) ) } )
73+ } ) ) )
7574 . then ( res => {
7675 etag = res . ETag ;
7776 return s3 . send ( new HeadObjectCommand ( {
7877 Bucket : sourceBucketName ,
7978 Key : sourceObjName ,
8079 } ) ) ;
81- } ) . then ( ( ) => {
82- return s3 . send ( new CreateMultipartUploadCommand ( {
80+ } ) . then ( ( ) => s3 . send ( new CreateMultipartUploadCommand ( {
8381 Bucket : destBucketName ,
8482 Key : destObjName ,
8583 } ) ) . then ( initiateRes => {
8684 uploadId = initiateRes . UploadId ;
87- } ) } ) . catch ( err => {
85+ } ) ) . catch ( err => {
8886 process . stdout . write ( `Error in outer beforeEach: ${ err } \n` ) ;
8987 throw err ;
9088 } ) ;
@@ -108,21 +106,18 @@ describe('Object Part Copy', () => {
108106
109107
110108 it ( 'should copy a part from a source bucket to a different ' +
111- 'destination bucket' , ( ) => {
112- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName ,
109+ 'destination bucket' , ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName ,
113110 Key : destObjName ,
114111 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
115112 PartNumber : 1 ,
116113 UploadId : uploadId ,
117114 } ) ) . then ( res => {
118115 assert . strictEqual ( res . CopyPartResult . ETag , etag ) ;
119116 assert ( res . CopyPartResult . LastModified ) ;
120- } ) ;
121- } ) ;
117+ } ) ) ;
122118
123119 it ( 'should copy a part from a source bucket to a different ' +
124- 'destination bucket and complete the MPU' , ( ) => {
125- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName ,
120+ 'destination bucket and complete the MPU' , ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName ,
126121 Key : destObjName ,
127122 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
128123 PartNumber : 1 ,
@@ -146,16 +141,13 @@ describe('Object Part Copy', () => {
146141 assert . strictEqual ( res . ETag ,
147142 '"db77ebbae9e9f5a244a26b86193ad818-1"' ) ;
148143 } ) ;
149- } ) ;
150- } ) ;
144+ } ) ) ;
151145
152- it ( 'should return InvalidArgument error given invalid range' , ( ) => {
153- return s3 . send ( new PutObjectCommand ( {
146+ it ( 'should return InvalidArgument error given invalid range' , ( ) => s3 . send ( new PutObjectCommand ( {
154147 Bucket : sourceBucketName ,
155148 Key : sourceObjName ,
156149 Body : Buffer . alloc ( oneHundredMBPlus11 , 'packing' ) ,
157- } ) ) . then ( ( ) => {
158- return s3 . send ( new UploadPartCopyCommand ( {
150+ } ) ) . then ( ( ) => s3 . send ( new UploadPartCopyCommand ( {
159151 Bucket : destBucketName ,
160152 Key : destObjName ,
161153 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
@@ -164,67 +156,57 @@ describe('Object Part Copy', () => {
164156 CopySourceRange : 'bad-range-parameter' ,
165157 } ) ) . catch ( err => {
166158 checkError ( err , 'InvalidArgument' ) ;
167- } ) } ) ;
168- } ) ;
159+ } ) ) ) ;
169160
170161 it ( 'should return EntityTooLarge error if attempt to copy ' +
171162 'object larger than max and do not specify smaller ' +
172- 'range in request' , ( ) => {
173- return s3 . send ( new PutObjectCommand ( {
163+ 'range in request' , ( ) => s3 . send ( new PutObjectCommand ( {
174164 Bucket : sourceBucketName ,
175165 Key : sourceObjName ,
176166 Body : Buffer . alloc ( oneHundredMBPlus11 , 'packing' ) ,
177- } ) ) . then ( ( ) => {
178- return s3 . send ( new UploadPartCopyCommand ( {
167+ } ) ) . then ( ( ) => s3 . send ( new UploadPartCopyCommand ( {
179168 Bucket : destBucketName ,
180169 Key : destObjName ,
181170 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
182171 PartNumber : 1 ,
183172 UploadId : uploadId ,
184- } ) ) } ) . catch ( err => {
173+ } ) ) ) . catch ( err => {
185174 checkError ( err , 'EntityTooLarge' ) ;
186- } ) ;
187- } ) ;
175+ } ) ) ;
188176
189177 it ( 'should return EntityTooLarge error if attempt to copy ' +
190178 'object larger than max and specify too large ' +
191- 'range in request' , ( ) => {
192- return s3 . send ( new PutObjectCommand ( {
179+ 'range in request' , ( ) => s3 . send ( new PutObjectCommand ( {
193180 Bucket : sourceBucketName ,
194181 Key : sourceObjName ,
195182 Body : Buffer . alloc ( oneHundredMBPlus11 , 'packing' ) ,
196- } ) ) . then ( ( ) => {
197- return s3 . send ( new UploadPartCopyCommand ( {
183+ } ) ) . then ( ( ) => s3 . send ( new UploadPartCopyCommand ( {
198184 Bucket : destBucketName ,
199185 Key : destObjName ,
200186 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
201187 PartNumber : 1 ,
202188 UploadId : uploadId ,
203189 CopySourceRange : `bytes=0-${ oneHundredMBPlus11 } ` ,
204- } ) ) } ) . catch ( err => {
190+ } ) ) ) . catch ( err => {
205191 checkError ( err , 'EntityTooLarge' ) ;
206- } ) ;
207- } ) ;
192+ } ) ) ;
208193
209194 it ( 'should succeed if attempt to copy ' +
210195 'object larger than max but specify acceptable ' +
211- 'range in request' , ( ) => {
212- return s3 . send ( new PutObjectCommand ( {
196+ 'range in request' , ( ) => s3 . send ( new PutObjectCommand ( {
213197 Bucket : sourceBucketName ,
214198 Key : sourceObjName ,
215199 Body : Buffer . alloc ( oneHundredMBPlus11 , 'packing' ) ,
216- } ) ) . then ( ( ) => {
217- return s3 . send ( new UploadPartCopyCommand ( {
200+ } ) ) . then ( ( ) => s3 . send ( new UploadPartCopyCommand ( {
218201 Bucket : destBucketName ,
219202 Key : destObjName ,
220203 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
221204 PartNumber : 1 ,
222205 UploadId : uploadId ,
223206 CopySourceRange : 'bytes=0-100' ,
224- } ) ) } ) . catch ( err => {
207+ } ) ) ) . catch ( err => {
225208 checkNoError ( err ) ;
226- } ) ;
227- } ) ;
209+ } ) ) ;
228210
229211 it ( 'should copy a 0 byte object part from a source bucket to a ' +
230212 'different destination bucket and complete the MPU' , ( ) => {
@@ -233,8 +215,7 @@ describe('Object Part Copy', () => {
233215 Bucket : sourceBucketName ,
234216 Key : sourceObjName ,
235217 Body : '' ,
236- } ) ) . then ( ( ) => {
237- return s3 . send ( new UploadPartCopyCommand ( {
218+ } ) ) . then ( ( ) => s3 . send ( new UploadPartCopyCommand ( {
238219 Bucket : destBucketName ,
239220 Key : destObjName ,
240221 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
@@ -258,7 +239,7 @@ describe('Object Part Copy', () => {
258239 // AWS confirmed final ETag for MPU
259240 assert . strictEqual ( res . ETag , '"59adb24ef3cdbe0297f05b395827453f-1"' ) ;
260241 } ) ;
261- } ) } ) ;
242+ } ) ) ;
262243 } ) ;
263244
264245 it ( 'should copy a part using a range header from a source bucket ' +
@@ -641,59 +622,49 @@ describe('Object Part Copy', () => {
641622 } ) ;
642623
643624 it ( 'should return an error if no such upload initiated' ,
644- ( ) => {
645- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
625+ ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
646626 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
647627 PartNumber : 1 ,
648628 UploadId : 'madeupuploadid444233232' ,
649629 } ) ) . catch ( err => {
650630 checkError ( err , 'NoSuchUpload' ) ;
651- } ) ;
652- } ) ;
631+ } ) ) ;
653632
654633 it ( 'should return an error if attempt to copy from nonexistent bucket' ,
655- ( ) => {
656- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
634+ ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
657635 CopySource : `nobucket453234/${ sourceObjName } ` ,
658636 PartNumber : 1 ,
659637 UploadId : uploadId ,
660638 } ) ) . catch ( err => {
661639 checkError ( err , 'NoSuchBucket' ) ;
662- } ) ;
663- } ) ;
640+ } ) ) ;
664641
665642 it ( 'should return an error if attempt to copy to nonexistent bucket' ,
666- ( ) => {
667- return s3 . send ( new UploadPartCopyCommand ( { Bucket : 'nobucket453234' , Key : destObjName ,
643+ ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : 'nobucket453234' , Key : destObjName ,
668644 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
669645 PartNumber : 1 ,
670646 UploadId : uploadId ,
671647 } ) ) . catch ( err => {
672648 checkError ( err , 'NoSuchBucket' ) ;
673- } ) ;
674- } ) ;
649+ } ) ) ;
675650
676651 it ( 'should return an error if attempt to copy nonexistent object' ,
677- ( ) => {
678- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
652+ ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
679653 CopySource : `${ sourceBucketName } /nokey` ,
680654 PartNumber : 1 ,
681655 UploadId : uploadId ,
682656 } ) ) . catch ( err => {
683657 checkError ( err , 'NoSuchKey' ) ;
684- } ) ;
685- } ) ;
658+ } ) ) ;
686659
687660 it ( 'should return an error if use invalid part number' ,
688- ( ) => {
689- return s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
661+ ( ) => s3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName , Key : destObjName ,
690662 CopySource : `${ sourceBucketName } /nokey` ,
691663 PartNumber : 10001 ,
692664 UploadId : uploadId ,
693665 } ) ) . catch ( err => {
694666 checkError ( err , 'InvalidArgument' ) ;
695- } ) ;
696- } ) ;
667+ } ) ) ;
697668
698669 const describeColdStorage = hasColdStorage ? describe : describe . skip ;
699670 describeColdStorage ( 'with cold storage' , ( ) => {
@@ -817,48 +788,43 @@ describe('Object Part Copy', () => {
817788 ) ;
818789
819790 it ( 'should not allow an account without read persmission on the ' +
820- 'source object to copy the object' , ( ) => {
821- return otherAccountS3 . send ( new UploadPartCopyCommand ( { Bucket : otherAccountBucket ,
791+ 'source object to copy the object' , ( ) => otherAccountS3 . send ( new UploadPartCopyCommand (
792+ { Bucket : otherAccountBucket ,
822793 Key : otherAccountKey ,
823794 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
824795 PartNumber : 1 ,
825796 UploadId : otherAccountUploadId ,
826797 } ) ) . catch (
827798 err => {
828799 checkError ( err , 'AccessDenied' ) ;
829- } ) ;
830- } ) ;
800+ } ) ) ;
831801
832802 it ( 'should not allow an account without write persmission on the ' +
833803 'destination bucket to upload part copy the object' , ( ) => {
834804 otherAccountS3 . send ( new PutObjectCommand ( { Bucket : otherAccountBucket ,
835- Key : otherAccountKey , Body : '' } ) ) . then ( ( ) => {
836- return otherAccountS3 . send ( new UploadPartCopyCommand ( { Bucket : destBucketName ,
805+ Key : otherAccountKey , Body : '' } ) ) . then ( ( ) => otherAccountS3 . send (
806+ new UploadPartCopyCommand ( { Bucket : destBucketName ,
837807 Key : destObjName ,
838808 CopySource : `${ otherAccountBucket } /${ otherAccountKey } ` ,
839809 PartNumber : 1 ,
840810 UploadId : uploadId ,
841- } ) ) . catch ( err => checkError ( err , 'AccessDenied' ) ) ;
842- } ) ;
811+ } ) ) . catch ( err => checkError ( err , 'AccessDenied' ) ) ) ;
843812 } ) ;
844813
845814 it ( 'should allow an account with read permission on the ' +
846815 'source object and write permission on the destination ' +
847- 'bucket to upload part copy the object' , ( ) => {
848- return s3 . send ( new PutObjectAclCommand ( { Bucket : sourceBucketName ,
849- Key : sourceObjName , ACL : 'public-read' } ) ) . then ( ( ) => {
850- return otherAccountS3 . send ( new UploadPartCopyCommand ( { Bucket : otherAccountBucket ,
816+ 'bucket to upload part copy the object' , ( ) => s3 . send ( new PutObjectAclCommand (
817+ { Bucket : sourceBucketName ,
818+ Key : sourceObjName , ACL : 'public-read' } ) ) . then ( ( ) => otherAccountS3 . send ( new UploadPartCopyCommand (
819+ { Bucket : otherAccountBucket ,
851820 Key : otherAccountKey ,
852821 CopySource : `${ sourceBucketName } /${ sourceObjName } ` ,
853822 PartNumber : 1 ,
854823 UploadId : otherAccountUploadId ,
855- } ) ) . catch (
856- err => {
824+ } ) ) . catch ( err => {
857825 checkNoError ( err ) ;
858826 }
859- ) ;
860- } ) ;
861- } ) ;
827+ ) ) ) ;
862828 } ) ;
863829 } ) ;
864830} ) ;
0 commit comments