From cd6862dab82c788b5dd516740ec0445fa9b56c68 Mon Sep 17 00:00:00 2001 From: Will Toozs Date: Thu, 4 Jul 2024 19:20:29 +0200 Subject: [PATCH] lint --- lib/api/api.js | 7 ++-- .../aws-node-sdk/test/object/post.js | 35 ++++++++----------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/api/api.js b/lib/api/api.js index 493dd30c08..cdd59b7fc0 100644 --- a/lib/api/api.js +++ b/lib/api/api.js @@ -240,16 +240,15 @@ const api = { if (algoOK && credOK && dateOK && sigOK && policyOK) { return next(null); } + return undefined; }); bb.on('finish', () => { - if (!algoOK || !credOK || !dateOK || !sigOK || !policyOK) { - return next(errors.InvalidRequest); - } // if fields are found but no file, continue - if (!fileEventData) { + if ((algoOK && credOK && dateOK && sigOK && policyOK) && !fileEventData) { return next(null); } + return next(errors.InvalidRequest); }); bb.on('error', (err) => { diff --git a/tests/functional/aws-node-sdk/test/object/post.js b/tests/functional/aws-node-sdk/test/object/post.js index ef3005e3d2..ce341c3bd2 100644 --- a/tests/functional/aws-node-sdk/test/object/post.js +++ b/tests/functional/aws-node-sdk/test/object/post.js @@ -548,7 +548,8 @@ describe('POST object', () => { const error = result.Error; assert.equal(error.Code[0], 'SignatureDoesNotMatch'); - assert.equal(error.Message[0], 'The request signature we calculated does not match the signature you provided.'); + assert.equal(error.Message[0], + 'The request signature we calculated does not match the signature you provided.'); return done(); }); }); @@ -581,25 +582,23 @@ describe('POST object', () => { formData.append('file', fs.createReadStream(path.join(__dirname, 'test-file.txt'))); - formData.getLength((err, length) => { + return formData.getLength((err, length) => { if (err) { return done(err); } - axios.post(url, formData, { + return axios.post(url, formData, { headers: { ...formData.getHeaders(), 'Content-Length': length, }, }) - .then(() => { - done(new Error('Request should not succeed with an invalid signature')); - }) + .then(() => done(new Error('Request should not succeed with an invalid signature'))) .catch(err => { assert.ok(err.response, 'Error should be returned by axios'); // Parse the XML error response - xml2js.parseString(err.response.data, (parseErr, result) => { + return xml2js.parseString(err.response.data, (parseErr, result) => { if (parseErr) { return done(parseErr); } @@ -610,7 +609,7 @@ describe('POST object', () => { 'SignatureDoesNotMatch', 'Expected SignatureDoesNotMatch error code' ); - done(); + return done(); }); }); }); @@ -643,27 +642,25 @@ describe('POST object', () => { return done(err); } - axios.post(url, formData, { + return axios.post(url, formData, { headers: { ...formData.getHeaders(), 'Content-Length': length, }, }) - .then(() => { - done(new Error('Request should not succeed with an invalid keys')); - }) + .then(() => done(new Error('Request should not succeed with an invalid keys'))) .catch(err => { assert.ok(err.response, 'Error should be returned by axios'); // Parse the XML error response - xml2js.parseString(err.response.data, (parseErr, result) => { + return xml2js.parseString(err.response.data, (parseErr, result) => { if (parseErr) { return done(parseErr); } const error = result.Error; assert.equal(error.Code[0], 'InvalidAccessKeyId', 'Expected InvalidAccessKeyId error code'); - done(); + return done(); }); }); }); @@ -698,27 +695,25 @@ describe('POST object', () => { return done(err); } - axios.post(url, formData, { + return axios.post(url, formData, { headers: { ...formData.getHeaders(), 'Content-Length': length, }, }) - .then(() => { - done(new Error('Request should not succeed with an invalid credential')); - }) + .then(() => done(new Error('Request should not succeed with an invalid credential'))) .catch(err => { assert.ok(err.response, 'Error should be returned by axios'); // Parse the XML error response - xml2js.parseString(err.response.data, (parseErr, result) => { + return xml2js.parseString(err.response.data, (parseErr, result) => { if (parseErr) { return done(parseErr); } const error = result.Error; assert.equal(error.Code[0], 'InvalidArgument', 'Expected InvalidArgument error code'); - done(); + return done(); }); }); });