Skip to content

Commit 6774391

Browse files
trivikrsrchase
authored andcommitted
fix: use httpRequestOptions in signature-v4 (#623)
1 parent bb37235 commit 6774391

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/signature-v4/src/getCanonicalHeaders.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe("getCanonicalHeaders", () => {
6565
});
6666

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

8080
expect(
8181
getCanonicalHeaders(

packages/signature-v4/src/getCanonicalQuery.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { getCanonicalQuery } from "./getCanonicalQuery";
22
import { HttpRequest } from "@aws-sdk/protocol-http";
33

4-
const request = new HttpRequest({
4+
const httpRequestOptions = {
55
method: "POST",
66
protocol: "https:",
77
path: "/",
88
headers: {},
99
hostname: "foo.us-east-1.amazonaws.com"
10-
});
10+
};
1111

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

1717
it("should serialize simple key => value pairs", () => {
1818
expect(
1919
getCanonicalQuery(
2020
new HttpRequest({
21-
...request,
21+
...httpRequestOptions,
2222
query: { fizz: "buzz", foo: "bar" }
2323
})
2424
)
@@ -29,7 +29,7 @@ describe("getCanonicalQuery", () => {
2929
expect(
3030
getCanonicalQuery(
3131
new HttpRequest({
32-
...request,
32+
...httpRequestOptions,
3333
query: { foo: "bar", baz: "quux", fizz: "buzz" }
3434
})
3535
)
@@ -40,7 +40,7 @@ describe("getCanonicalQuery", () => {
4040
expect(
4141
getCanonicalQuery(
4242
new HttpRequest({
43-
...request,
43+
...httpRequestOptions,
4444
query: { "🐎": "🦄", "💩": "☃️" }
4545
})
4646
)
@@ -51,7 +51,7 @@ describe("getCanonicalQuery", () => {
5151
expect(
5252
getCanonicalQuery(
5353
new HttpRequest({
54-
...request,
54+
...httpRequestOptions,
5555
query: {
5656
"x-amz-signature": "foo",
5757
"X-Amz-Signature": "bar",
@@ -66,7 +66,7 @@ describe("getCanonicalQuery", () => {
6666
expect(
6767
getCanonicalQuery(
6868
new HttpRequest({
69-
...request,
69+
...httpRequestOptions,
7070
query: { foo: ["bar", "baz"] }
7171
})
7272
)
@@ -77,7 +77,7 @@ describe("getCanonicalQuery", () => {
7777
expect(
7878
getCanonicalQuery(
7979
new HttpRequest({
80-
...request,
80+
...httpRequestOptions,
8181
query: { snap: ["pop", "crackle"] }
8282
})
8383
)
@@ -88,7 +88,7 @@ describe("getCanonicalQuery", () => {
8888
expect(
8989
getCanonicalQuery(
9090
new HttpRequest({
91-
...request,
91+
...httpRequestOptions,
9292
query: { "🐎": ["💩", "🦄"] }
9393
})
9494
)
@@ -99,7 +99,7 @@ describe("getCanonicalQuery", () => {
9999
expect(
100100
getCanonicalQuery(
101101
new HttpRequest({
102-
...request,
102+
...httpRequestOptions,
103103
query: { foo: "bar", baz: new Uint8Array(0) as any }
104104
})
105105
)

0 commit comments

Comments
 (0)