Search in sources :

Example 31 with ExtractableResponse

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

the class VerifyPayloadHandlingComponentTest method verify_SerializedObject_response_payload_is_sent_as_serialized_json.

@Test
public void verify_SerializedObject_response_payload_is_sent_as_serialized_json() throws IOException, InterruptedException {
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(SerializableObjectPayloadReturner.MATCHING_PATH).log().all().when().post().then().log().all().statusCode(200).extract();
    String responsePayload = response.asString();
    String expectedHash = response.header(RESPONSE_PAYLOAD_HASH_HEADER_KEY);
    String actualHash = getHashForPayload(responsePayload.getBytes(CharsetUtil.UTF_8));
    assertThat(actualHash).isEqualTo(expectedHash);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Test(org.junit.Test)

Example 32 with ExtractableResponse

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

the class VerifyPayloadHandlingComponentTest method verify_request_payload_received_for_widget_input_type.

@Test
public void verify_request_payload_received_for_widget_input_type() throws JsonProcessingException {
    SerializableObject widget = new SerializableObject(UUID.randomUUID().toString(), generateRandomBytes(32));
    String requestPayload = objectMapper.writeValueAsString(widget);
    String payloadHash = getHashForPayload(requestPayload.getBytes(CharsetUtil.UTF_8));
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(WidgetTypeDeserializer.MATCHING_PATH).header(REQUEST_PAYLOAD_HASH_HEADER_KEY, payloadHash).body(requestPayload).log().all().when().post().then().log().all().statusCode(200).extract();
    String responsePayload = response.asString();
    assertThat(responsePayload).isEqualTo("success_widget");
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) 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