Skip to content

Commit

Permalink
test(protocoltests): validate resolvedHost from httpRequestTests (#6175)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jun 6, 2024
1 parent eedf0d5 commit ec83f87
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ it("Ec2QueryEndpointTrait:Request", async () => {
expect(r.headers["content-type"]).toBeDefined();
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `Action=EndpointOperation&Version=2020-01-08`;
Expand Down Expand Up @@ -391,6 +394,9 @@ it("Ec2QueryEndpointTraitWithHostLabel:Request", async () => {
expect(r.headers["content-type"]).toBeDefined();
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `Action=EndpointWithHostLabelOperation&Version=2020-01-08&Label=bar`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ it("AwsJson10EndpointTrait:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `{}`;
Expand Down Expand Up @@ -288,6 +291,9 @@ it("AwsJson10EndpointTraitWithHostLabel:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `{\"label\": \"bar\"}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ it("AwsJson11EndpointTrait:Request", async () => {
expect(r.headers["x-amz-target"]).toBeDefined();
expect(r.headers["x-amz-target"]).toBe("JsonProtocol.EndpointOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `{}`;
Expand Down Expand Up @@ -518,6 +521,9 @@ it("AwsJson11EndpointTraitWithHostLabel:Request", async () => {
expect(r.headers["x-amz-target"]).toBeDefined();
expect(r.headers["x-amz-target"]).toBe("JsonProtocol.EndpointWithHostLabelOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `{\"label\": \"bar\"}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ it("AwsQueryEndpointTrait:Request", async () => {
expect(r.headers["content-type"]).toBeDefined();
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `Action=EndpointOperation&Version=2020-01-08`;
Expand Down Expand Up @@ -391,6 +394,9 @@ it("AwsQueryEndpointTraitWithHostLabel:Request", async () => {
expect(r.headers["content-type"]).toBeDefined();
expect(r.headers["content-type"]).toBe("application/x-www-form-urlencoded");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `Action=EndpointWithHostLabelOperation&Version=2020-01-08&label=bar`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,9 @@ it("RestJsonEndpointTrait:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/EndpointOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeFalsy();
}
});
Expand Down Expand Up @@ -1666,6 +1669,9 @@ it("RestJsonEndpointTraitWithHostLabel:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/EndpointWithHostLabelOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `{\"label\": \"bar\"}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,9 @@ it("RestXmlEndpointTrait:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/EndpointOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.example.com");

expect(r.body).toBeFalsy();
}
});
Expand Down Expand Up @@ -925,6 +928,9 @@ it("RestXmlEndpointTraitWithHostLabelAndHttpBinding:Request", async () => {
expect(r.headers["x-amz-account-id"]).toBeDefined();
expect(r.headers["x-amz-account-id"]).toBe("bar");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("bar.example.com");

expect(r.body).toBeFalsy();
}
});
Expand Down Expand Up @@ -957,6 +963,9 @@ it("RestXmlEndpointTraitWithHostLabel:Request", async () => {
expect(r.method).toBe("POST");
expect(r.path).toBe("/EndpointWithHostLabelOperation");

expect(r.headers["host"]).toBeDefined();
expect(r.headers["host"]).toBe("foo.bar.example.com");

expect(r.body).toBeDefined();
const utf8Encoder = client.config.utf8Encoder;
const bodyString = `<EndpointWithHostLabelOperationRequest>
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-clients/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Update this commit when taking up new changes from smithy-typescript.
module.exports = {
// Use full commit hash as we explicitly fetch it.
SMITHY_TS_COMMIT: "cf9d6fe3483ba027f98e87d1921c32dd94e2c1f9",
SMITHY_TS_COMMIT: "78cb9a8fa99a2983d44e63f13266f093dacde90a",
};

if (module.exports.SMITHY_TS_COMMIT.length < 40) {
Expand Down

0 comments on commit ec83f87

Please sign in to comment.