@@ -49,6 +49,13 @@ const backendClients = [
4949 } ,
5050 } ,
5151] ;
52+ const awsPartChecksumFields = [
53+ [ 'ChecksumCRC32' , 'crc32' , 'crc32-value' ] ,
54+ [ 'ChecksumCRC32C' , 'crc32c' , 'crc32c-value' ] ,
55+ [ 'ChecksumCRC64NVME' , 'crc64nvme' , 'crc64-value' ] ,
56+ [ 'ChecksumSHA1' , 'sha1' , 'sha1-value' ] ,
57+ [ 'ChecksumSHA256' , 'sha256' , 'sha256-value' ] ,
58+ ] ;
5259const log = new DummyRequestLogger ( ) ;
5360let sandbox ;
5461
@@ -285,6 +292,64 @@ describe('external backend clients', () => {
285292 assert ( firstPart . value ) ;
286293 assert . strictEqual ( firstPart . value . ETag . includes ( '"' ) , false ) ;
287294 } ) ;
295+
296+ awsPartChecksumFields . forEach ( ( [ checksumField , checksumAlgorithm , checksumValue ] ) => {
297+ it ( `${ backend . name } listParts() should normalize ${ checksumField } ` , async ( ) => {
298+ const key = 'externalBackendTestKey' ;
299+ const bucketName = 'externalBackendTestBucket' ;
300+ const lastModified = new Date ( ) ;
301+ sandbox . stub ( testClient . _client , 'send' ) . resolves ( {
302+ IsTruncated : true ,
303+ Parts : [
304+ {
305+ PartNumber : 1 ,
306+ ETag : '"part-etag-1"' ,
307+ Size : 1024 ,
308+ LastModified : lastModified ,
309+ [ checksumField ] : checksumValue ,
310+ } ,
311+ ] ,
312+ } ) ;
313+
314+ const storedParts = await listPartsAsync ( key , 'uploadId-123' , bucketName , 0 , 1000 , log ) ;
315+
316+ assert . strictEqual ( storedParts . IsTruncated , true ) ;
317+ assert . strictEqual ( storedParts . Contents . length , 1 ) ;
318+ assert . deepStrictEqual ( storedParts . Contents [ 0 ] , {
319+ partNumber : 1 ,
320+ value : {
321+ Size : 1024 ,
322+ ETag : 'part-etag-1' ,
323+ LastModified : lastModified ,
324+ ChecksumAlgorithm : checksumAlgorithm ,
325+ ChecksumValue : checksumValue ,
326+ } ,
327+ } ) ;
328+ } ) ;
329+ } ) ;
330+
331+ it ( `${ backend . name } listParts() should omit absent checksum fields` , async ( ) => {
332+ const key = 'externalBackendTestKey' ;
333+ const bucketName = 'externalBackendTestBucket' ;
334+ sandbox . stub ( testClient . _client , 'send' ) . resolves ( {
335+ IsTruncated : false ,
336+ Parts : [
337+ {
338+ PartNumber : 2 ,
339+ ETag : '"part-etag-2"' ,
340+ Size : 2048 ,
341+ LastModified : new Date ( ) ,
342+ } ,
343+ ] ,
344+ } ) ;
345+
346+ const storedParts = await listPartsAsync ( key , 'uploadId-123' , bucketName , 0 , 1000 , log ) ;
347+ const { value } = storedParts . Contents [ 0 ] ;
348+
349+ assert . strictEqual ( value . ETag , 'part-etag-2' ) ;
350+ assert . strictEqual ( value . ChecksumAlgorithm , undefined ) ;
351+ assert . strictEqual ( value . ChecksumValue , undefined ) ;
352+ } ) ;
288353 }
289354
290355 it ( `${ backend . name } createMPU() should trim metadata and forward tagging` , async ( ) => {
0 commit comments