Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(client-s3): update functional tests to verify trailing checksums #3367

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions clients/client-s3/test/flexibleChecksums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,24 @@ describe("Flexible Checksums", () => {
});
});

it(`when body is sent as a stream`, async () => {
it(`when body is sent as a stream`, (done) => {
const requestChecksumValidator: BuildMiddleware<any, any> = (next) => async (args) => {
// middleware intercept the request and return it early
const request = args.request as HttpRequest;
const { headers } = request;
const { headers, body } = request;
expect(headers["content-length"]).to.be.undefined;
expect(headers["content-encoding"]).to.equal("aws-chunked");
expect(headers["transfer-encoding"]).to.equal("chunked");
expect(headers["x-amz-content-sha256"]).to.equal("STREAMING-UNSIGNED-PAYLOAD-TRAILER");
expect(headers["x-amz-trailer"]).to.equal(checksumHeader);
body.on("data", (data) => {
const stringValue = data.toString();
if (stringValue.startsWith(checksumHeader)) {
const receivedChecksum = stringValue.replace("\r\n", "").split(":")[1];
expect(receivedChecksum).to.equal(checksumValue);
done();
}
});
return { output: {} as any, response: {} as any };
};

Expand All @@ -93,7 +101,7 @@ describe("Flexible Checksums", () => {
});

const bodyStream = getBodyAsReadableStream(body);
return await client.putObject({
client.putObject({
Bucket: "bucket",
Key: "key",
Body: bodyStream,
Expand Down