Skip to content

Commit cd6862d

Browse files
author
Will Toozs
committed
lint
1 parent d7da573 commit cd6862d

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

lib/api/api.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,15 @@ const api = {
240240
if (algoOK && credOK && dateOK && sigOK && policyOK) {
241241
return next(null);
242242
}
243+
return undefined;
243244
});
244245

245246
bb.on('finish', () => {
246-
if (!algoOK || !credOK || !dateOK || !sigOK || !policyOK) {
247-
return next(errors.InvalidRequest);
248-
}
249247
// if fields are found but no file, continue
250-
if (!fileEventData) {
248+
if ((algoOK && credOK && dateOK && sigOK && policyOK) && !fileEventData) {
251249
return next(null);
252250
}
251+
return next(errors.InvalidRequest);
253252
});
254253

255254
bb.on('error', (err) => {

tests/functional/aws-node-sdk/test/object/post.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ describe('POST object', () => {
548548

549549
const error = result.Error;
550550
assert.equal(error.Code[0], 'SignatureDoesNotMatch');
551-
assert.equal(error.Message[0], 'The request signature we calculated does not match the signature you provided.');
551+
assert.equal(error.Message[0],
552+
'The request signature we calculated does not match the signature you provided.');
552553
return done();
553554
});
554555
});
@@ -581,25 +582,23 @@ describe('POST object', () => {
581582

582583
formData.append('file', fs.createReadStream(path.join(__dirname, 'test-file.txt')));
583584

584-
formData.getLength((err, length) => {
585+
return formData.getLength((err, length) => {
585586
if (err) {
586587
return done(err);
587588
}
588589

589-
axios.post(url, formData, {
590+
return axios.post(url, formData, {
590591
headers: {
591592
...formData.getHeaders(),
592593
'Content-Length': length,
593594
},
594595
})
595-
.then(() => {
596-
done(new Error('Request should not succeed with an invalid signature'));
597-
})
596+
.then(() => done(new Error('Request should not succeed with an invalid signature')))
598597
.catch(err => {
599598
assert.ok(err.response, 'Error should be returned by axios');
600599

601600
// Parse the XML error response
602-
xml2js.parseString(err.response.data, (parseErr, result) => {
601+
return xml2js.parseString(err.response.data, (parseErr, result) => {
603602
if (parseErr) {
604603
return done(parseErr);
605604
}
@@ -610,7 +609,7 @@ describe('POST object', () => {
610609
'SignatureDoesNotMatch',
611610
'Expected SignatureDoesNotMatch error code'
612611
);
613-
done();
612+
return done();
614613
});
615614
});
616615
});
@@ -643,27 +642,25 @@ describe('POST object', () => {
643642
return done(err);
644643
}
645644

646-
axios.post(url, formData, {
645+
return axios.post(url, formData, {
647646
headers: {
648647
...formData.getHeaders(),
649648
'Content-Length': length,
650649
},
651650
})
652-
.then(() => {
653-
done(new Error('Request should not succeed with an invalid keys'));
654-
})
651+
.then(() => done(new Error('Request should not succeed with an invalid keys')))
655652
.catch(err => {
656653
assert.ok(err.response, 'Error should be returned by axios');
657654

658655
// Parse the XML error response
659-
xml2js.parseString(err.response.data, (parseErr, result) => {
656+
return xml2js.parseString(err.response.data, (parseErr, result) => {
660657
if (parseErr) {
661658
return done(parseErr);
662659
}
663660

664661
const error = result.Error;
665662
assert.equal(error.Code[0], 'InvalidAccessKeyId', 'Expected InvalidAccessKeyId error code');
666-
done();
663+
return done();
667664
});
668665
});
669666
});
@@ -698,27 +695,25 @@ describe('POST object', () => {
698695
return done(err);
699696
}
700697

701-
axios.post(url, formData, {
698+
return axios.post(url, formData, {
702699
headers: {
703700
...formData.getHeaders(),
704701
'Content-Length': length,
705702
},
706703
})
707-
.then(() => {
708-
done(new Error('Request should not succeed with an invalid credential'));
709-
})
704+
.then(() => done(new Error('Request should not succeed with an invalid credential')))
710705
.catch(err => {
711706
assert.ok(err.response, 'Error should be returned by axios');
712707

713708
// Parse the XML error response
714-
xml2js.parseString(err.response.data, (parseErr, result) => {
709+
return xml2js.parseString(err.response.data, (parseErr, result) => {
715710
if (parseErr) {
716711
return done(parseErr);
717712
}
718713

719714
const error = result.Error;
720715
assert.equal(error.Code[0], 'InvalidArgument', 'Expected InvalidArgument error code');
721-
done();
716+
return done();
722717
});
723718
});
724719
});

0 commit comments

Comments
 (0)