Search in sources :

Example 16 with ExtractableResponse

use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.

the class VerifyPreEndpointExecutionWorkChainComponentTest method verify_proxy_work_chain_stops_at_downstream_content_validation_if_content_validator_blows_up.

@Test
public void verify_proxy_work_chain_stops_at_downstream_content_validation_if_content_validator_blows_up() throws IOException, InterruptedException {
    String fooValue = UUID.randomUUID().toString();
    String postData = objectMapper.writeValueAsString(new PostObj(fooValue));
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(WorkChainProxyEndpoint.PROXY_MATCHING_PATH).header(PROXY_ROUTER_DESTINATION_PORT_HEADER_KEY, String.valueOf(downstreamServerConfig.endpointsPort())).header(BLOW_UP_IN_CONTENT_VALIDATOR_HEADER_KEY, "true").body(postData).log().all().when().post().then().log().all().extract();
    Thread.sleep(10);
    verifyErrorReceived(response, CONTENT_VALIDATOR_API_ERROR);
    verifyAsyncWorkerChainExecution(2, 1, 1, true, false);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Test(org.junit.Test)

Example 17 with ExtractableResponse

use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.

the class VerifyPreEndpointExecutionWorkChainComponentTest method verify_proxy_work_chain_stops_at_downstream_content_deserialization_if_content_deserializer_blows_up.

@Test
public void verify_proxy_work_chain_stops_at_downstream_content_deserialization_if_content_deserializer_blows_up() throws IOException, InterruptedException {
    String fooValue = UUID.randomUUID().toString();
    String postData = objectMapper.writeValueAsString(new PostObj(fooValue));
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(WorkChainProxyEndpoint.PROXY_MATCHING_PATH).header(PROXY_ROUTER_DESTINATION_PORT_HEADER_KEY, String.valueOf(downstreamServerConfig.endpointsPort())).header(BLOW_UP_IN_CONTENT_DESERIALIZER_HEADER_KEY, "true").body(postData).log().all().when().post().then().log().all().extract();
    Thread.sleep(10);
    verifyErrorReceived(response, SampleCoreApiError.MALFORMED_REQUEST);
    verifyAsyncWorkerChainExecution(2, 1, 0, true, false);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Test(org.junit.Test)

Example 18 with ExtractableResponse

use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.

the class VerifyPreEndpointExecutionWorkChainComponentTest method verify_work_chain_stops_at_content_deserialization_if_content_deserializer_blows_up.

@Test
public void verify_work_chain_stops_at_content_deserialization_if_content_deserializer_blows_up() throws IOException, InterruptedException {
    String fooValue = UUID.randomUUID().toString();
    String postData = objectMapper.writeValueAsString(new PostObj(fooValue));
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(WorkChainEndpoint.WORK_CHAIN_MATCHING_PATH).header(BLOW_UP_IN_CONTENT_DESERIALIZER_HEADER_KEY, "true").body(postData).log().all().when().post().then().log().all().extract();
    Thread.sleep(10);
    verifyErrorReceived(response, SampleCoreApiError.MALFORMED_REQUEST);
    verifyAsyncWorkerChainExecution(1, 1, 0, false, false);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Test(org.junit.Test)

Example 19 with ExtractableResponse

use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.

the class VerifyRequestSizeValidationComponentTest method should_return_expected_response_when_endpoint_disabled_ContentLength_header_above_global_size_validation.

@Test
public void should_return_expected_response_when_endpoint_disabled_ContentLength_header_above_global_size_validation() {
    ExtractableResponse response = given().baseUri(BASE_URI).port(serverConfig.endpointsPort()).basePath(BasicEndpointWithRequestSizeValidationDisabled.MATCHING_PATH).log().all().body(generatePayloadOfSizeInBytes(GLOBAL_MAX_REQUEST_SIZE + 100)).when().post().then().log().headers().extract();
    assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.OK.code());
    assertThat(response.asString()).isEqualTo(BasicEndpointWithRequestSizeValidationDisabled.RESPONSE_PAYLOAD);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Test(org.junit.Test)

Example 20 with ExtractableResponse

use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.

the class ArchaiusServerTest method verify_essential_behavior.

@Test
public void verify_essential_behavior() throws Exception {
    // given
    setAppAndEnvironment("archaiusserver", "compiletimetest");
    int port = findFreePort();
    ArchaiusServer server = generateArchaiusServer(port);
    assertThat(System.getProperty("org.jboss.logging.provider")).isNull();
    // when
    server.launchServer(null);
    ExtractableResponse<Response> response = given().baseUri("http://localhost").port(port).when().get(SomeEndpoint.MATCHING_PATH).then().extract();
    // then
    assertThat(response.statusCode()).isEqualTo(200);
    assertThat(response.asString()).isEqualTo("overridevalue");
    assertThat(System.getProperty("org.jboss.logging.provider")).isEqualTo("slf4j");
    assertThat(ResourceLeakDetector.getLevel()).isEqualTo(ResourceLeakDetector.Level.PARANOID);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) StandardEndpoint(com.nike.riposte.server.http.StandardEndpoint) Endpoint(com.nike.riposte.server.http.Endpoint) Test(org.junit.Test)

Aggregations

ExtractableResponse (io.restassured.response.ExtractableResponse)32 Test (org.junit.Test)30 Endpoint (com.nike.riposte.server.http.Endpoint)5 StandardEndpoint (com.nike.riposte.server.http.StandardEndpoint)5 Response (io.restassured.response.Response)4 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)3 ApiError (com.nike.backstopper.apierror.ApiError)1 ApiErrorBase (com.nike.backstopper.apierror.ApiErrorBase)1 SimpleProxyRouterEndpoint (com.nike.riposte.server.http.impl.SimpleProxyRouterEndpoint)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1