Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Toozs committed Jul 4, 2024
1 parent d7da573 commit cd6862d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
7 changes: 3 additions & 4 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
35 changes: 15 additions & 20 deletions tests/functional/aws-node-sdk/test/object/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down Expand Up @@ -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);
}
Expand All @@ -610,7 +609,7 @@ describe('POST object', () => {
'SignatureDoesNotMatch',
'Expected SignatureDoesNotMatch error code'
);
done();
return done();
});
});
});
Expand Down Expand Up @@ -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();
});
});
});
Expand Down Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit cd6862d

Please sign in to comment.