Skip to content

Commit

Permalink
Merge branch 'bugfix/ARSN-6/reverse-ARSN_3' into tmp/octopus/w/8.1/bu…
Browse files Browse the repository at this point in the history
…gfix/ARSN-6/reverse-ARSN_3
  • Loading branch information
bert-e committed Jul 28, 2021
2 parents 0bdcd86 + 66a48f4 commit 681740f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/auth/v4/createCanonicalRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ function createCanonicalRequest(params) {
.trim().replace(/\s+/g, ' ');
return `${signedHeader}:${trimmedHeader}\n`;
}
// nginx will strip the actual expect header so add value of
// header back here if it was included as a signed header
if (signedHeader === 'expect') {
return `${signedHeader}:100-continue\n`;
}
// handle case where signed 'header' is actually query param
return `${signedHeader}:${pQuery[signedHeader]}\n`;
});
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/auth/v4/createCanonicalRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ describe('createCanonicalRequest function', () => {
assert.strictEqual(actualOutput, expectedOutput);
});

it('should construct a canonical request that contains a ' +
'signed expect header even if expect header value was ' +
'stripped by the load balancer', () => {
const params = {
pHttpVerb: 'PUT',
pResource: '/test.txt',
pQuery: {},
pHeaders: {
host: 'examplebucket.s3.amazonaws.com',
},
pSignedHeaders: 'expect;host',
payloadChecksum: 'UNSIGNED-PAYLOAD',
};
const expectedOutput = 'PUT\n' +
'/test.txt\n\n' +
'expect:100-continue\n' +
'host:examplebucket.s3.amazonaws.com\n\n' +
'expect;host\n' +
'UNSIGNED-PAYLOAD';
const actualOutput = createCanonicalRequest(params);
assert.strictEqual(actualOutput, expectedOutput);
});

it('should trim white space in a canonical header value so that ' +
'there is no white space before or after a value and any sequential ' +
'white space becomes a single space', () => {
Expand Down

0 comments on commit 681740f

Please sign in to comment.