Skip to content

Commit

Permalink
fixup: bug fixes post fct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Toozs committed Jul 8, 2024
1 parent ce04e83 commit 7cdb373
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/functional/aws-node-sdk/test/object/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const calculateFields = (ak, sk, bucketName, additionalConditions) => {

const now = new Date();
const formattedDate = now.toISOString().replace(/[:-]|\.\d{3}/g, '');
const shortFormattedDate = formatDate(now);
let shortFormattedDate = formatDate(now);

const credential = `${ak}/${shortFormattedDate}/${region}/${service}/aws4_request`;
const conditionsFields = [
Expand All @@ -54,6 +54,9 @@ const calculateFields = (ak, sk, bucketName, additionalConditions) => {
const index = conditionsFields.findIndex(condition => condition.hasOwnProperty(key));
if (index !== -1) {
conditionsFields[index][key] = value;
if (key === 'x-amz-date') {
shortFormattedDate = value.split('T')[0];
}
} else {
conditionsFields.push({ [key]: value });
}
Expand All @@ -69,11 +72,11 @@ const calculateFields = (ak, sk, bucketName, additionalConditions) => {
const signature = crypto.createHmac('sha256', signingKey).update(policyBase64).digest('hex');

const returnFields = [
{ name: 'X-Amz-Credential', value: credential },
{ name: 'X-Amz-Algorithm', value: 'AWS4-HMAC-SHA256' },
{ name: 'X-Amz-Signature', value: signature },
{ name: 'X-Amz-Date', value: formattedDate },
{ name: 'Policy', value: policyBase64 },
{ name: 'x-amz-credential', value: credential },
{ name: 'x-amz-algorithm', value: 'AWS4-HMAC-SHA256' },
{ name: 'x-amz-signature', value: signature },
{ name: 'x-amz-date', value: formattedDate },
{ name: 'policy', value: policyBase64 },
{ name: 'bucket', value: bucketName },
{ name: 'key', value: filename },
];
Expand All @@ -95,7 +98,6 @@ const calculateFields = (ak, sk, bucketName, additionalConditions) => {
return returnFields;
};


describe('POST object', () => {
let bucketUtil;
let config;
Expand Down Expand Up @@ -372,7 +374,16 @@ describe('POST object', () => {
})
.catch(err => {
assert.equal(err.response.status, 400);
done();
xml2js.parseString(err.response.data, (parseErr, result) => {

Check warning on line 377 in tests/functional/aws-node-sdk/test/object/post.js

View workflow job for this annotation

GitHub Actions / linting-coverage

Expected to return a value at the end of this function
if (parseErr) {
return done(parseErr);
}

const error = result.Error;
assert.equal(error.Code[0], 'InvalidArgument');
assert.equal(error.Message[0], 'POST requires exactly one file upload per request.');
done();
});
});
});
});
Expand Down

0 comments on commit 7cdb373

Please sign in to comment.