use of com.nike.riposte.server.testutils.ComponentTestUtils.NettyHttpClientResponse in project riposte by Nike-Inc.
the class VerifyDecoderFailedResultIsHandledTest method endpoints_should_be_reachable_with_barely_valid_initial_line_length_values.
@DataProvider(value = { "STANDARD_ENDPOINT", "PROXY_ENDPOINT" })
@Test
public void endpoints_should_be_reachable_with_barely_valid_initial_line_length_values(EndpointTypeScenario scenario) throws Exception {
// given
String barelyAcceptableUri = generateUriForInitialLineLength(HttpMethod.GET, scenario.matchingPathBase, CUSTOM_REQUEST_DECODER_CONFIG.maxInitialLineLength());
Pair<String, Object> barelyAcceptableHeader = generateHeaderForHeaderLineLength(CUSTOM_REQUEST_DECODER_CONFIG.maxHeaderSize());
NettyHttpClientRequestBuilder request = request().withMethod(HttpMethod.GET).withUri(barelyAcceptableUri).withHeaders(barelyAcceptableHeader);
// when
NettyHttpClientResponse serverResponse = request.execute(scenario.serverPort, incompleteCallTimeoutMillis);
// then
assertThat(serverResponse.statusCode).isEqualTo(200);
assertThat(serverResponse.payload).isEqualTo(scenario.successfulResponsePayload);
}
use of com.nike.riposte.server.testutils.ComponentTestUtils.NettyHttpClientResponse in project riposte by Nike-Inc.
the class VerifyCornerCasesComponentTest method invalid_http_call_with_invalid_URL_escaping_should_result_in_expected_400_error.
@Test
public void invalid_http_call_with_invalid_URL_escaping_should_result_in_expected_400_error() throws Exception {
// given
// Incorrectly escaped URLs cause a blowup in RequestInfoImpl when it tries to decode the URL. We can trigger
// this by putting a % character that is not followed by a proper escape sequence.
NettyHttpClientRequestBuilder request = request().withMethod(HttpMethod.GET).withUri("%notAnEscapeSequence");
// when
NettyHttpClientResponse response = request.execute(downstreamServerConfig.endpointsPort(), 3000);
// then
verifyErrorReceived(response.payload, response.statusCode, new ApiErrorWithMetadata(SampleCoreApiError.MALFORMED_REQUEST, Pair.of("cause", "Invalid HTTP request")));
}
Aggregations