use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyRequestSizeValidationComponentTest method should_return_expected_response_when_ContentLength_header_not_exceeding_global_request_size.
@Test
public void should_return_expected_response_when_ContentLength_header_not_exceeding_global_request_size() {
ExtractableResponse response = given().baseUri(BASE_URI).port(serverConfig.endpointsPort()).basePath(BasicEndpoint.MATCHING_PATH).log().all().body(generatePayloadOfSizeInBytes(GLOBAL_MAX_REQUEST_SIZE)).when().post().then().log().headers().extract();
assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.OK.code());
assertThat(response.asString()).isEqualTo(BasicEndpoint.RESPONSE_PAYLOAD);
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyPayloadHandlingComponentTest method verify_request_payload_raw_bytes_received_for_void_input_type.
@Test
public void verify_request_payload_raw_bytes_received_for_void_input_type() {
byte[] bytePayload = generateRandomBytes(64);
String payloadHash = getHashForPayload(bytePayload);
ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(VoidTypeDeserializer.MATCHING_PATH).header(REQUEST_PAYLOAD_HASH_HEADER_KEY, payloadHash).body(bytePayload).log().all().when().post().then().log().all().statusCode(200).extract();
String responsePayload = response.asString();
assertThat(responsePayload).isEqualTo("success_void");
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyPreEndpointExecutionWorkChainComponentTest method verify_work_chain_stops_at_content_validator_if_content_validator_blows_up.
@Test
public void verify_work_chain_stops_at_content_validator_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(WorkChainEndpoint.WORK_CHAIN_MATCHING_PATH).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(1, 1, 1, false, false);
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class TypesafeConfigServerTest method verify_essential_behavior.
@Test
public void verify_essential_behavior() throws Exception {
// given
setAppAndEnvironment("typesafeconfigserver", "compiletimetest");
int port = findFreePort();
TypesafeConfigServer server = generateTypesafeConfigServer(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);
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class MetricsComponentTest method sendServerRequest.
protected Future<Map<String, String>> sendServerRequest(String endpointUrl) {
return executor.submit(() -> {
long start = System.currentTimeMillis();
ExtractableResponse<Response> response1 = given().when().get(endpointUrl).then().extract();
long end = System.currentTimeMillis();
String s = response1.asString();
logger.info("********* server call to {} returned {} in {} millis *************", endpointUrl, s, (end - start));
int statusCode = response1.statusCode();
int expectedStatusCode = 200;
if (endpointUrl.contains("?error="))
expectedStatusCode = Integer.parseInt(endpointUrl.substring(endpointUrl.indexOf("?error=") + 7));
assertEquals(expectedStatusCode, statusCode);
return mapper.readValue(s, Map.class);
});
}
Aggregations