Skip to content

Commit 78cb9a8

Browse files
authored
Validate resolvedHost from httpRequestTests (#1300)
1 parent cf9d6fe commit 78cb9a8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ private void writeHttpRequestAssertions(HttpRequestTestCase testCase) {
448448

449449
writeHttpHeaderAssertions(testCase);
450450
writeHttpQueryAssertions(testCase);
451+
writeHttpHostAssertion(testCase);
451452
testCase.getBody().ifPresent(body -> {
452453
writeHttpBodyAssertions(body, testCase.getBodyMediaType().orElse("UNKNOWN"), true);
453454
});
@@ -521,6 +522,14 @@ private void writeHttpHeaderAssertions(HttpMessageTestCase testCase) {
521522
writer.write("");
522523
}
523524

525+
private void writeHttpHostAssertion(HttpRequestTestCase testCase) {
526+
testCase.getResolvedHost().ifPresent(resolvedHost -> {
527+
writer.write("expect(r.headers[\"host\"]).toBeDefined();");
528+
writer.write("expect(r.headers[\"host\"]).toBe($S);", resolvedHost);
529+
writer.write("");
530+
});
531+
}
532+
524533
private void writeHttpBodyAssertions(String body, String mediaType, boolean isClientTest) {
525534
// If we expect an empty body, expect it to be falsy.
526535
if (body.isEmpty()) {

0 commit comments

Comments
 (0)