@@ -14,7 +14,8 @@ const { cleanup, DummyRequestLogger, makeAuthInfo, versioningTestUtils }
1414const mpuUtils = require ( '../utils/mpuUtils' ) ;
1515const metadata = require ( '../metadataswitch' ) ;
1616const { data } = require ( '../../../lib/data/wrapper' ) ;
17- const { objectLocationConstraintHeader } = require ( '../../../constants' ) ;
17+ const constants = require ( '../../../constants' ) ;
18+ const { objectLocationConstraintHeader } = constants ;
1819const { fakeMetadataArchive } = require ( '../../functional/aws-node-sdk/test/utils/init' ) ;
1920const { config } = require ( '../../../lib/Config' ) ;
2021
@@ -640,3 +641,47 @@ describe('objectCopy with objectKeyByteLimit', () => {
640641 } ) ;
641642 } ) ;
642643} ) ;
644+
645+ describe ( 'objectCopy source size limit' , ( ) => {
646+ const testPutObjectRequest = versioningTestUtils . createPutObjectRequest ( sourceBucketName , objectKey , objData [ 0 ] ) ;
647+ const sourceSize = objData [ 0 ] . length ;
648+ let originalMaximumUploadSize ;
649+
650+ before ( done => {
651+ cleanup ( ) ;
652+ originalMaximumUploadSize = constants . maximumAllowedUploadSize ;
653+ async . series ( [
654+ callback => bucketPut ( authInfo , putDestBucketRequest , log , callback ) ,
655+ callback => bucketPut ( authInfo , putSourceBucketRequest , log , callback ) ,
656+ callback => objectPut ( authInfo , testPutObjectRequest , undefined , log , callback ) ,
657+ ] , done ) ;
658+ } ) ;
659+
660+ after ( ( ) => {
661+ constants . maximumAllowedUploadSize = originalMaximumUploadSize ;
662+ cleanup ( ) ;
663+ } ) ;
664+
665+ it ( 'should allow CopyObject when source size equals the limit' , done => {
666+ constants . maximumAllowedUploadSize = sourceSize ;
667+ const testObjectCopyRequest = _createObjectCopyRequest ( destBucketName ) ;
668+ objectCopy ( authInfo , testObjectCopyRequest , sourceBucketName , objectKey ,
669+ undefined , log , err => {
670+ assert . ifError ( err ) ;
671+ done ( ) ;
672+ } ) ;
673+ } ) ;
674+
675+ it ( 'should reject CopyObject when source size exceeds the limit' , done => {
676+ constants . maximumAllowedUploadSize = sourceSize - 1 ;
677+ const testObjectCopyRequest = _createObjectCopyRequest ( destBucketName ) ;
678+ objectCopy ( authInfo , testObjectCopyRequest , sourceBucketName , objectKey ,
679+ undefined , log , err => {
680+ assert ( err ) ;
681+ assert . strictEqual ( err . is . InvalidRequest , true ) ;
682+ assert . match ( err . description ,
683+ / T h e s p e c i f i e d c o p y s o u r c e i s l a r g e r t h a n t h e m a x i m u m a l l o w a b l e s i z e f o r a c o p y s o u r c e / ) ;
684+ done ( ) ;
685+ } ) ;
686+ } ) ;
687+ } ) ;
0 commit comments