Skip to content

Commit 30a3d62

Browse files
authored
test(client-s3): update functional tests to verify trailing checksums (#3367)
1 parent c013190 commit 30a3d62

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

clients/client-s3/test/flexibleChecksums.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,24 @@ describe("Flexible Checksums", () => {
7373
});
7474
});
7575

76-
it(`when body is sent as a stream`, async () => {
76+
it(`when body is sent as a stream`, (done) => {
7777
const requestChecksumValidator: BuildMiddleware<any, any> = (next) => async (args) => {
7878
// middleware intercept the request and return it early
7979
const request = args.request as HttpRequest;
80-
const { headers } = request;
80+
const { headers, body } = request;
8181
expect(headers["content-length"]).to.be.undefined;
8282
expect(headers["content-encoding"]).to.equal("aws-chunked");
8383
expect(headers["transfer-encoding"]).to.equal("chunked");
8484
expect(headers["x-amz-content-sha256"]).to.equal("STREAMING-UNSIGNED-PAYLOAD-TRAILER");
8585
expect(headers["x-amz-trailer"]).to.equal(checksumHeader);
86+
body.on("data", (data) => {
87+
const stringValue = data.toString();
88+
if (stringValue.startsWith(checksumHeader)) {
89+
const receivedChecksum = stringValue.replace("\r\n", "").split(":")[1];
90+
expect(receivedChecksum).to.equal(checksumValue);
91+
done();
92+
}
93+
});
8694
return { output: {} as any, response: {} as any };
8795
};
8896

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

95103
const bodyStream = getBodyAsReadableStream(body);
96-
return await client.putObject({
104+
client.putObject({
97105
Bucket: "bucket",
98106
Key: "key",
99107
Body: bodyStream,

0 commit comments

Comments
 (0)