Skip to content

Commit

Permalink
add test: httpPostWithInvalidHostHeader (#1345)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis committed Oct 17, 2022
1 parent 737b9a3 commit 02d6913
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -50,6 +50,7 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import static com.github.tomakehurst.wiremock.client.WireMock.anyRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
Expand Down Expand Up @@ -184,6 +185,27 @@ void httpPostHappyPath(final String description, final OkHttpClient okHttp) thro
verify(0, getRequestedFor(anyUrl()));
}

@ParameterizedTest
@MethodSource("arguments")
void httpPostWithInvalidHostHeader(final String description, final OkHttpClient okHttp) throws Exception {
final WireMock wireMock = wmRuntimeInfo.getWireMock();
wireMock.register(
post(path)
.willReturn(
ok()
.withBody("Thank you next")));

Request request = new Request.Builder()
.url(zuulBaseUri + path)
.addHeader("Host", "_invalid_hostname_")
.post(RequestBody.create("Simple POST request body".getBytes(StandardCharsets.UTF_8)))
.build();
Response response = okHttp.newCall(request).execute();
assertThat(response.code()).isEqualTo(500);

verify(0, anyRequestedFor(anyUrl()));
}

@ParameterizedTest
@MethodSource("arguments")
void httpGetFailsDueToOriginReadTimeout(final String description, final OkHttpClient okHttp) throws Exception {
Expand Down

0 comments on commit 02d6913

Please sign in to comment.