@@ -234,6 +234,40 @@ describe('validateChecksumsNoChunking CRC32, CRC32C, SHA1, SHA256, CRC64NVME', (
234234 assert . deepStrictEqual ( result . details . algorithms , [ 'x-amz-checksum-sha1' , 'x-amz-checksum-sha256' ] ) ;
235235 } ) ;
236236
237+ it ( 'should ignore x-amz-checksum-algorithm alongside a valid x-amz-checksum-<algo> value' , async ( ) => {
238+ const body = 'sha256 data' ;
239+ const headers = {
240+ 'content-type' : 'application/json' ,
241+ 'x-amz-checksum-algorithm' : 'SHA256' ,
242+ 'x-amz-checksum-sha256' : 'jS/UevcoKxbM33kmPFujS72ior/9/i374VmGvbTAwAc=' ,
243+ } ;
244+ const result = await validateChecksumsNoChunking ( headers , body ) ;
245+ assert . ifError ( result ) ;
246+ } ) ;
247+
248+ it ( 'should ignore x-amz-checksum-type alongside a valid x-amz-checksum-<algo> value' , async ( ) => {
249+ const body = 'sha256 data' ;
250+ const headers = {
251+ 'content-type' : 'application/json' ,
252+ 'x-amz-checksum-type' : 'FULL_OBJECT' ,
253+ 'x-amz-checksum-sha256' : 'jS/UevcoKxbM33kmPFujS72ior/9/i374VmGvbTAwAc=' ,
254+ } ;
255+ const result = await validateChecksumsNoChunking ( headers , body ) ;
256+ assert . ifError ( result ) ;
257+ } ) ;
258+
259+ it ( 'should ignore both x-amz-checksum-algorithm and x-amz-checksum-type when combined with a value' , async ( ) => {
260+ const body = 'sha256 data' ;
261+ const headers = {
262+ 'content-type' : 'application/json' ,
263+ 'x-amz-checksum-algorithm' : 'SHA256' ,
264+ 'x-amz-checksum-type' : 'FULL_OBJECT' ,
265+ 'x-amz-checksum-sha256' : 'jS/UevcoKxbM33kmPFujS72ior/9/i374VmGvbTAwAc=' ,
266+ } ;
267+ const result = await validateChecksumsNoChunking ( headers , body ) ;
268+ assert . ifError ( result ) ;
269+ } ) ;
270+
237271 for ( const algo of algos ) {
238272 it ( 'should return error AlgoNotSupported if x-amz-sdk-checksum-algorithm algo not supported' , async ( ) => {
239273 const headers = {
@@ -591,6 +625,31 @@ describe('getChecksumDataFromHeaders', () => {
591625 assert . strictEqual ( result . error , ChecksumError . MultipleChecksumTypes ) ;
592626 } ) ;
593627
628+ it ( 'should ignore x-amz-checksum-algorithm alongside a valid x-amz-checksum-<algo> value' , ( ) => {
629+ const result = getChecksumDataFromHeaders ( {
630+ 'x-amz-checksum-algorithm' : 'SHA256' ,
631+ 'x-amz-checksum-sha256' : validDigests . sha256 ,
632+ } ) ;
633+ assert . deepStrictEqual ( result , { algorithm : 'sha256' , isTrailer : false , expected : validDigests . sha256 } ) ;
634+ } ) ;
635+
636+ it ( 'should ignore x-amz-checksum-type alongside a valid x-amz-checksum-<algo> value' , ( ) => {
637+ const result = getChecksumDataFromHeaders ( {
638+ 'x-amz-checksum-type' : 'FULL_OBJECT' ,
639+ 'x-amz-checksum-sha256' : validDigests . sha256 ,
640+ } ) ;
641+ assert . deepStrictEqual ( result , { algorithm : 'sha256' , isTrailer : false , expected : validDigests . sha256 } ) ;
642+ } ) ;
643+
644+ it ( 'should ignore both x-amz-checksum-algorithm and x-amz-checksum-type when combined with a value' , ( ) => {
645+ const result = getChecksumDataFromHeaders ( {
646+ 'x-amz-checksum-algorithm' : 'SHA256' ,
647+ 'x-amz-checksum-type' : 'FULL_OBJECT' ,
648+ 'x-amz-checksum-sha256' : validDigests . sha256 ,
649+ } ) ;
650+ assert . deepStrictEqual ( result , { algorithm : 'sha256' , isTrailer : false , expected : validDigests . sha256 } ) ;
651+ } ) ;
652+
594653 it ( 'should return MissingCorresponding when x-amz-sdk-checksum-algorithm has no x-amz-checksum- or trailer' , ( ) => {
595654 const result = getChecksumDataFromHeaders ( { 'x-amz-sdk-checksum-algorithm' : 'crc32' } ) ;
596655 assert . strictEqual ( result . error , ChecksumError . MissingCorresponding ) ;
0 commit comments