Skip to content

Commit ec83f87

Browse files
authored
test(protocoltests): validate resolvedHost from httpRequestTests (#6175)
1 parent eedf0d5 commit ec83f87

File tree

7 files changed

+40
-1
lines changed

7 files changed

+40
-1
lines changed

private/aws-protocoltests-ec2/test/functional/ec2query.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ it("Ec2QueryEndpointTrait:Request", async () => {
352352
expect(r.headers["content-type"]).toBeDefined();
353353
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");
354354

355+
expect(r.headers["host"]).toBeDefined();
356+
expect(r.headers["host"]).toBe("foo.example.com");
357+
355358
expect(r.body).toBeDefined();
356359
const utf8Encoder = client.config.utf8Encoder;
357360
const bodyString = `Action=EndpointOperation&Version=2020-01-08`;
@@ -391,6 +394,9 @@ it("Ec2QueryEndpointTraitWithHostLabel:Request", async () => {
391394
expect(r.headers["content-type"]).toBeDefined();
392395
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");
393396

397+
expect(r.headers["host"]).toBeDefined();
398+
expect(r.headers["host"]).toBe("foo.bar.example.com");
399+
394400
expect(r.body).toBeDefined();
395401
const utf8Encoder = client.config.utf8Encoder;
396402
const bodyString = `Action=EndpointWithHostLabelOperation&Version=2020-01-08&Label=bar`;

private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ it("AwsJson10EndpointTrait:Request", async () => {
252252
expect(r.method).toBe("POST");
253253
expect(r.path).toBe("/");
254254

255+
expect(r.headers["host"]).toBeDefined();
256+
expect(r.headers["host"]).toBe("foo.example.com");
257+
255258
expect(r.body).toBeDefined();
256259
const utf8Encoder = client.config.utf8Encoder;
257260
const bodyString = `{}`;
@@ -288,6 +291,9 @@ it("AwsJson10EndpointTraitWithHostLabel:Request", async () => {
288291
expect(r.method).toBe("POST");
289292
expect(r.path).toBe("/");
290293

294+
expect(r.headers["host"]).toBeDefined();
295+
expect(r.headers["host"]).toBe("foo.bar.example.com");
296+
291297
expect(r.body).toBeDefined();
292298
const utf8Encoder = client.config.utf8Encoder;
293299
const bodyString = `{\"label\": \"bar\"}`;

private/aws-protocoltests-json/test/functional/awsjson1_1.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ it("AwsJson11EndpointTrait:Request", async () => {
477477
expect(r.headers["x-amz-target"]).toBeDefined();
478478
expect(r.headers["x-amz-target"]).toBe("JsonProtocol.EndpointOperation");
479479

480+
expect(r.headers["host"]).toBeDefined();
481+
expect(r.headers["host"]).toBe("foo.example.com");
482+
480483
expect(r.body).toBeDefined();
481484
const utf8Encoder = client.config.utf8Encoder;
482485
const bodyString = `{}`;
@@ -518,6 +521,9 @@ it("AwsJson11EndpointTraitWithHostLabel:Request", async () => {
518521
expect(r.headers["x-amz-target"]).toBeDefined();
519522
expect(r.headers["x-amz-target"]).toBe("JsonProtocol.EndpointWithHostLabelOperation");
520523

524+
expect(r.headers["host"]).toBeDefined();
525+
expect(r.headers["host"]).toBe("foo.bar.example.com");
526+
521527
expect(r.body).toBeDefined();
522528
const utf8Encoder = client.config.utf8Encoder;
523529
const bodyString = `{\"label\": \"bar\"}`;

private/aws-protocoltests-query/test/functional/awsquery.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ it("AwsQueryEndpointTrait:Request", async () => {
352352
expect(r.headers["content-type"]).toBeDefined();
353353
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");
354354

355+
expect(r.headers["host"]).toBeDefined();
356+
expect(r.headers["host"]).toBe("foo.example.com");
357+
355358
expect(r.body).toBeDefined();
356359
const utf8Encoder = client.config.utf8Encoder;
357360
const bodyString = `Action=EndpointOperation&Version=2020-01-08`;
@@ -391,6 +394,9 @@ it("AwsQueryEndpointTraitWithHostLabel:Request", async () => {
391394
expect(r.headers["content-type"]).toBeDefined();
392395
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");
393396

397+
expect(r.headers["host"]).toBeDefined();
398+
expect(r.headers["host"]).toBe("foo.bar.example.com");
399+
394400
expect(r.body).toBeDefined();
395401
const utf8Encoder = client.config.utf8Encoder;
396402
const bodyString = `Action=EndpointWithHostLabelOperation&Version=2020-01-08&label=bar`;

private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,9 @@ it("RestJsonEndpointTrait:Request", async () => {
16341634
expect(r.method).toBe("POST");
16351635
expect(r.path).toBe("/EndpointOperation");
16361636

1637+
expect(r.headers["host"]).toBeDefined();
1638+
expect(r.headers["host"]).toBe("foo.example.com");
1639+
16371640
expect(r.body).toBeFalsy();
16381641
}
16391642
});
@@ -1666,6 +1669,9 @@ it("RestJsonEndpointTraitWithHostLabel:Request", async () => {
16661669
expect(r.method).toBe("POST");
16671670
expect(r.path).toBe("/EndpointWithHostLabelOperation");
16681671

1672+
expect(r.headers["host"]).toBeDefined();
1673+
expect(r.headers["host"]).toBe("foo.bar.example.com");
1674+
16691675
expect(r.body).toBeDefined();
16701676
const utf8Encoder = client.config.utf8Encoder;
16711677
const bodyString = `{\"label\": \"bar\"}`;

private/aws-protocoltests-restxml/test/functional/restxml.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ it("RestXmlEndpointTrait:Request", async () => {
888888
expect(r.method).toBe("POST");
889889
expect(r.path).toBe("/EndpointOperation");
890890

891+
expect(r.headers["host"]).toBeDefined();
892+
expect(r.headers["host"]).toBe("foo.example.com");
893+
891894
expect(r.body).toBeFalsy();
892895
}
893896
});
@@ -925,6 +928,9 @@ it("RestXmlEndpointTraitWithHostLabelAndHttpBinding:Request", async () => {
925928
expect(r.headers["x-amz-account-id"]).toBeDefined();
926929
expect(r.headers["x-amz-account-id"]).toBe("bar");
927930

931+
expect(r.headers["host"]).toBeDefined();
932+
expect(r.headers["host"]).toBe("bar.example.com");
933+
928934
expect(r.body).toBeFalsy();
929935
}
930936
});
@@ -957,6 +963,9 @@ it("RestXmlEndpointTraitWithHostLabel:Request", async () => {
957963
expect(r.method).toBe("POST");
958964
expect(r.path).toBe("/EndpointWithHostLabelOperation");
959965

966+
expect(r.headers["host"]).toBeDefined();
967+
expect(r.headers["host"]).toBe("foo.bar.example.com");
968+
960969
expect(r.body).toBeDefined();
961970
const utf8Encoder = client.config.utf8Encoder;
962971
const bodyString = `<EndpointWithHostLabelOperationRequest>

scripts/generate-clients/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Update this commit when taking up new changes from smithy-typescript.
22
module.exports = {
33
// Use full commit hash as we explicitly fetch it.
4-
SMITHY_TS_COMMIT: "cf9d6fe3483ba027f98e87d1921c32dd94e2c1f9",
4+
SMITHY_TS_COMMIT: "78cb9a8fa99a2983d44e63f13266f093dacde90a",
55
};
66

77
if (module.exports.SMITHY_TS_COMMIT.length < 40) {

0 commit comments

Comments
 (0)