Skip to content

Commit

Permalink
fix: use httpRequestOptions in signature-v4 (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jan 3, 2020
1 parent f226993 commit 4548971
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/signature-v4/src/getCanonicalHeaders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("getCanonicalHeaders", () => {
});

it("should allow specifying custom signable headers that override unsignable ones", () => {
const request: HttpRequest<never> = {
const request = new HttpRequest({
method: "POST",
protocol: "https:",
path: "/",
Expand All @@ -75,7 +75,7 @@ describe("getCanonicalHeaders", () => {
"user-agent": "foo-user"
},
hostname: "foo.us-east-1.amazonaws.com"
};
});

expect(
getCanonicalHeaders(
Expand Down
22 changes: 11 additions & 11 deletions packages/signature-v4/src/getCanonicalQuery.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { getCanonicalQuery } from "./getCanonicalQuery";
import { HttpRequest } from "@aws-sdk/protocol-http";

const request = new HttpRequest({
const httpRequestOptions = {
method: "POST",
protocol: "https:",
path: "/",
headers: {},
hostname: "foo.us-east-1.amazonaws.com"
});
};

describe("getCanonicalQuery", () => {
it("should return an empty string for requests with no querystring", () => {
expect(getCanonicalQuery(request)).toBe("");
expect(getCanonicalQuery(new HttpRequest(httpRequestOptions))).toBe("");
});

it("should serialize simple key => value pairs", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { fizz: "buzz", foo: "bar" }
})
)
Expand All @@ -29,7 +29,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { foo: "bar", baz: "quux", fizz: "buzz" }
})
)
Expand All @@ -40,7 +40,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { "🐎": "πŸ¦„", "πŸ’©": "β˜ƒοΈ" }
})
)
Expand All @@ -51,7 +51,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: {
"x-amz-signature": "foo",
"X-Amz-Signature": "bar",
Expand All @@ -66,7 +66,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { foo: ["bar", "baz"] }
})
)
Expand All @@ -77,7 +77,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { snap: ["pop", "crackle"] }
})
)
Expand All @@ -88,7 +88,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { "🐎": ["πŸ’©", "πŸ¦„"] }
})
)
Expand All @@ -99,7 +99,7 @@ describe("getCanonicalQuery", () => {
expect(
getCanonicalQuery(
new HttpRequest({
...request,
...httpRequestOptions,
query: { foo: "bar", baz: new Uint8Array(0) as any }
})
)
Expand Down

0 comments on commit 4548971

Please sign in to comment.