Skip to content

Commit a149729

Browse files
committed
CLDSRV-898: rm old test config setup & remove unused string concats
1 parent fdb29a1 commit a149729

5 files changed

Lines changed: 371 additions & 425 deletions

File tree

lib/api/apiUtils/integrity/validateChecksums.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const errTrailerNotSupported = errorInstances.InvalidRequest.customizeDescriptio
2929
);
3030
const errMPUAlgoNotSupported = errorInstances.InvalidRequest.customizeDescription(
3131
'Checksum algorithm provided is unsupported. ' +
32-
'Please try again with any of the valid types: ' +
33-
'[CRC32, CRC32C, CRC64NVME, SHA1, SHA256]',
32+
'Please try again with any of the valid types: [CRC32, CRC32C, CRC64NVME, SHA1, SHA256]',
3433
);
3534
const errMPUTypeInvalid = errorInstances.InvalidRequest.customizeDescription(
3635
'Value for x-amz-checksum-type header is invalid.',

lib/api/completeMultipartUpload.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,14 @@ function completeMultipartUpload(authInfo, request, log, callback) {
353353
// Legacy MPU created before checksumType was tracked.
354354
const typeErr = errorInstances.InvalidRequest.customizeDescription(
355355
'The upload was not created with a checksum mode. ' +
356-
'The complete request must not include a ' +
357-
'x-amz-checksum-type header.',
356+
'The complete request must not include a x-amz-checksum-type header.',
358357
);
359358
return next(typeErr, destBucket);
360359
}
361360
if (headerTypeUpper !== mpuType.toUpperCase()) {
362361
const typeErr = errorInstances.InvalidRequest.customizeDescription(
363-
`The upload was created using the ${mpuType} ` +
364-
'checksum mode. The complete request must ' +
365-
'use the same checksum mode.',
362+
`The upload was created using the ${mpuType} checksum mode. ` +
363+
'The complete request must use the same checksum mode.',
366364
);
367365
return next(typeErr, destBucket);
368366
}

tests/functional/raw-node/test/xAmzChecksum.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('Test x-amz-checksums', () => {
186186
for (const algo of algos) {
187187
for (const method of methods) {
188188
itSkipIfAWS(
189-
`${method.Name} should respond BadDigest ` + `with invalid x-amz-checksum-${algo.name.toLowerCase()}`,
189+
`${method.Name} should respond BadDigest with invalid x-amz-checksum-${algo.name.toLowerCase()}`,
190190
done => {
191191
const headers = {
192192
[`x-amz-checksum-${algo.name.toLowerCase()}`]: algo.validWrong,
@@ -274,8 +274,7 @@ describe('Test x-amz-checksums', () => {
274274
for (const algo of algos) {
275275
for (const method of methods) {
276276
itSkipIfAWS(
277-
`${method.Name} should not respond BadDigest if ` +
278-
`x-amz-checksum-${algo.name.toLowerCase()} is correct`,
277+
`${method.Name} should not respond BadDigest if x-amz-checksum-${algo.name.toLowerCase()} is correct`,
279278
done => {
280279
const url = `http://localhost:8000/${bucket}/${method.Key}?${method.Query}`;
281280
const req = new HttpRequestAuthV4(

tests/unit/api/apiUtils/integrity/validateChecksums.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ describe('validateMethodChecksumNoChunking', () => {
338338
describe('when checksum mismatches', () => {
339339
Object.keys(checksumedMethods).forEach(method => {
340340
it(`should return BadDigest error for ${method} when checksum mismatch`, async () => {
341-
config.integrityChecks[method] = true;
342-
343341
const body = 'Hello, World!';
344342
const wrongMd5 = '1B2M2Y8AsgTpgAmY7PhCfg==';
345343
const request = {
@@ -360,8 +358,6 @@ describe('validateMethodChecksumNoChunking', () => {
360358
describe('when checksum mismatches', () => {
361359
Object.keys(checksumedMethods).forEach(method => {
362360
it(`should return InvalidDigest error for ${method} when checksum mismatch`, async () => {
363-
config.integrityChecks[method] = true;
364-
365361
const body = 'Hello, World!';
366362
const wrongMd5 = 'wrongchecksum123=';
367363
const request = {
@@ -382,8 +378,6 @@ describe('validateMethodChecksumNoChunking', () => {
382378
describe('when no checksum is provided', () => {
383379
Object.keys(checksumedMethods).forEach(method => {
384380
it(`should return null for ${method} when no checksum is provided`, async () => {
385-
config.integrityChecks[method] = true;
386-
387381
const body = 'Hello, World!';
388382
const request = {
389383
apiMethod: method,
@@ -401,8 +395,6 @@ describe('validateMethodChecksumNoChunking', () => {
401395
describe('when checksum matches', () => {
402396
Object.keys(checksumedMethods).forEach(method => {
403397
it(`should return null for ${method} when checksum matches`, async () => {
404-
config.integrityChecks[method] = true;
405-
406398
const body = 'Hello, World!';
407399
const correctMd5 = crypto.createHash('md5').update(body, 'utf8').digest('base64');
408400
const request = {
@@ -443,9 +435,8 @@ describe('validateMethodChecksumNoChunking', () => {
443435
});
444436

445437
describe('when method is not in validation function mapping', () => {
446-
it('should return null for unsupported method even when enabled in config', async () => {
438+
it('should return null for unsupported method', async () => {
447439
const unsupportedMethod = 'someUnsupportedMethod';
448-
config.integrityChecks[unsupportedMethod] = true;
449440

450441
const body = 'Hello, World!';
451442
const wrongMd5 = 'wrongchecksum123=';
@@ -502,7 +493,6 @@ describe('validateMethodChecksumNoChunking', () => {
502493
const correctMd5 = crypto.createHash('md5').update(body, 'utf8').digest('base64');
503494

504495
it('should return null when Content-MD5 matches the body', async () => {
505-
config.integrityChecks.completeMultipartUpload = true;
506496
const request = {
507497
apiMethod: 'completeMultipartUpload',
508498
headers: { 'content-md5': correctMd5 },
@@ -513,7 +503,6 @@ describe('validateMethodChecksumNoChunking', () => {
513503
});
514504

515505
it('should return BadDigest when Content-MD5 does not match the body', async () => {
516-
config.integrityChecks.completeMultipartUpload = true;
517506
const request = {
518507
apiMethod: 'completeMultipartUpload',
519508
headers: { 'content-md5': '1B2M2Y8AsgTpgAmY7PhCfg==' },
@@ -524,7 +513,6 @@ describe('validateMethodChecksumNoChunking', () => {
524513
});
525514

526515
it('should return InvalidDigest when Content-MD5 is malformed', async () => {
527-
config.integrityChecks.completeMultipartUpload = true;
528516
const request = {
529517
apiMethod: 'completeMultipartUpload',
530518
headers: { 'content-md5': 'wrongchecksum123=' },
@@ -535,7 +523,6 @@ describe('validateMethodChecksumNoChunking', () => {
535523
});
536524

537525
it('should return null when no Content-MD5 header is present', async () => {
538-
config.integrityChecks.completeMultipartUpload = true;
539526
const request = {
540527
apiMethod: 'completeMultipartUpload',
541528
headers: {},
@@ -550,7 +537,6 @@ describe('validateMethodChecksumNoChunking', () => {
550537
// the other methods, this wrong x-amz-checksum-sha256 (treated
551538
// as a body digest) would return BadDigest. The md5-only path
552539
// must ignore it — the final-object validator handles it later.
553-
config.integrityChecks.completeMultipartUpload = true;
554540
const request = {
555541
apiMethod: 'completeMultipartUpload',
556542
headers: { 'x-amz-checksum-sha256': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' },

0 commit comments

Comments
 (0)