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

fix(middleware-apply-body-checksum): use lowercase content-md5 header #2645

Merged
merged 1 commit into from
Aug 5, 2021

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Aug 5, 2021

Issue

Refs: #2644 (comment)

Description

Uses lowercase name for content-md5 header to fix the following protocol test failure:

344 | FAIL protocol_tests/aws-restjson/tests/functional/restjson1.spec.ts (26.65 s)
345 | ● RestJsonHttpChecksumRequired:Request
346 |  
347 | expect(received).toBeDefined()
348 |  
349 | Received: undefined
350 |  
351 | 1918 \|     expect(r.path).toBe("/HttpChecksumRequired");
352 | 1919 \|
353 | > 1920 \|     expect(r.headers["content-md5"]).toBeDefined();
354 | \|                                      ^
355 | 1921 \|     expect(r.headers["content-md5"]).toBe("iB0/3YSo7maijL0IGOgA9g==");
356 | 1922 \|     expect(r.headers["content-type"]).toBeDefined();
357 | 1923 \|     expect(r.headers["content-type"]).toBe("application/json");
358 |  
359 | at Object.<anonymous>.it (tests/functional/restjson1.spec.ts:1920:38)

Testing

Verified that an example command which uses content-md5 header is successfully run

Code
import {
  S3Client,
  CreateBucketCommand,
  GetBucketLifecycleConfigurationCommand,
  PutBucketLifecycleConfigurationCommand,
  waitUntilBucketExists,
} from "../aws-sdk-js-v3/clients/client-s3/dist/cjs/index.js";

const region = "us-west-2";
const Bucket = `test-bucket-${Date.now()}`;
const client = new S3Client({ region });

client.middlewareStack.add(
  (next, context) => async (args) => {
    // Logs content-md5 header for PutBucketLifecycleConfigurationCommand
    console.log(args.request.headers["content-md5"]);
    return next(args);
  },
  {
    step: "finalizeRequest",
    name: "logHeadersMiddleware",
  }
);

const LifecycleConfiguration = {
  Rules: [
    {
      Expiration: { Days: 1 },
      ID: "TestUploads",
      Filter: { Prefix: "test" },
      Status: "Enabled",
    },
  ],
};

await client.send(new CreateBucketCommand({ Bucket }));
await waitUntilBucketExists({ client }, { Bucket });
await client.send(
  new PutBucketLifecycleConfigurationCommand({ Bucket, LifecycleConfiguration })
);
console.log(
  JSON.stringify(
    await client.send(new GetBucketLifecycleConfigurationCommand({ Bucket })),
    null,
    2
  )
);
Output
undefined
undefined
Cjf7B15n+E6KCLpIdWpijw==
undefined
{
  "$metadata": {
    "httpStatusCode": 200,
    "extendedRequestId": "z0rbTBowHwDo98YzHwBKespzJaLQ47t4wz28RFOgpIk0EXMgLPK4fXtFiubE0dny/6QupRsJP4E=",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "Rules": [
    {
      "Expiration": {
        "Days": 1
      },
      "ID": "TestUploads",
      "Filter": {
        "Prefix": "test"
      },
      "Status": "Enabled"
    }
  ]
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 6069f70
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@96de406). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2645   +/-   ##
=======================================
  Coverage        ?   60.61%           
=======================================
  Files           ?      515           
  Lines           ?    27689           
  Branches        ?     6804           
=======================================
  Hits            ?    16784           
  Misses          ?    10905           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96de406...6069f70. Read the comment docs.

@trivikr trivikr changed the title fix(middleware-apply-body-checksum): use lowercase name for content-md5 header fix(middleware-apply-body-checksum): use lowercase content-md5 header Aug 5, 2021
@trivikr trivikr merged commit e1f2dfc into aws:main Aug 5, 2021
@trivikr trivikr deleted the fix-lowercase-content-md5 branch August 5, 2021 18:14
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants