use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyMiscellaneousFunctionalityComponentTest method verify_proxy_router_response_modification_works_as_expected.
@Test
public void verify_proxy_router_response_modification_works_as_expected() throws IOException, InterruptedException {
ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(ProxyRouterResponseModificationEndpoint.MATCHING_PATH).log().all().when().get().then().log().headers().extract();
ApiError unmodifiedError = EmptyMetadataErrorThrower.ERROR_NO_METADATA;
assertThat(response.statusCode()).isEqualTo(ProxyRouterResponseModificationEndpoint.MODIFIED_HTTP_STATUS_RESPONSE_CODE);
assertThat(response.header(ProxyRouterResponseModificationEndpoint.ORIG_HTTP_STATUS_CODE_RESPONSE_HEADER_KEY)).isEqualTo(String.valueOf(unmodifiedError.getHttpStatusCode()));
ApiError expectedModifiedError = new ApiErrorBase(unmodifiedError.getName(), unmodifiedError.getErrorCode(), unmodifiedError.getMessage(), ProxyRouterResponseModificationEndpoint.MODIFIED_HTTP_STATUS_RESPONSE_CODE);
verifyErrorReceived(response, expectedModifiedError);
assertThat(response.asString()).doesNotContain("metadata");
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyBeforeAndAfterSecurityRequestAndResponseFiltersComponentTest method shouldOnlyExecuteBeforeSecurityRequestFilterWhenSecurityErrorThrown.
@Test
public void shouldOnlyExecuteBeforeSecurityRequestFilterWhenSecurityErrorThrown() {
ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(BasicEndpoint.MATCHING_PATH).header(FORCE_SECURITY_ERROR_HEADER_KEY, "true").log().all().when().get().then().log().headers().extract();
// Validate that the security validator was called and that it threw an exception.
assertThat(response.statusCode()).isEqualTo(401);
assertThat(response.header(SECURITY_VALIDATOR_EXECUTED_HEADER_KEY)).isEqualTo("true");
assertThat(response.header(SECURITY_VALIDATOR_THREW_ERROR_HEADER_KEY)).isEqualTo("true");
// Validate request filter methods were called.
assertThat(response.header(BEFORE_SECURITY_FIRST_CHUNK_FILTER_REQUEST_METHOD_EXECUTED_KEY)).isEqualTo("true");
assertThat(response.header(BEFORE_SECURITY_LAST_CHUNK_FILTER_REQUEST_METHOD_EXECUTED_KEY)).isEqualTo("false");
assertThat(response.header(AFTER_SECURITY_FIRST_CHUNK_FILTER_REQUEST_METHOD_EXECUTED_KEY)).isEqualTo("false");
assertThat(response.header(AFTER_SECURITY_LAST_CHUNK_FILTER_REQUEST_METHOD_EXECUTED_KEY)).isEqualTo("false");
// Validate response filter method was called.
assertThat(response.header(BEFORE_SECURITY_RESPONSE_FILTER_METHOD_EXECUTED_KEY)).isEqualTo(BEFORE_SECURITY_RESPONSE_FILTER_METHOD_EXECUTED_PAYLOAD);
assertThat(response.header(AFTER_SECURITY_RESPONSE_FILTER_METHOD_EXECUTED_KEY)).isEqualTo(AFTER_SECURITY_RESPONSE_FILTER_METHOD_EXECUTED_PAYLOAD);
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyMiscellaneousFunctionalityComponentTest method verify_populated_metadata_is_returned_in_error_contract.
@Test
public void verify_populated_metadata_is_returned_in_error_contract() throws IOException, InterruptedException {
ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(WithMetadataErrorThrower.MATCHING_PATH).log().all().when().get().then().log().headers().extract();
verifyErrorReceived(response, WithMetadataErrorThrower.ERROR_WITH_METADATA);
assertThat(response.asString()).contains("\"metadata\":{");
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class VerifyMiscellaneousFunctionalityComponentTest method verify_empty_metadata_is_stripped_from_error_contract.
@Test
public void verify_empty_metadata_is_stripped_from_error_contract() throws IOException, InterruptedException {
ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(EmptyMetadataErrorThrower.MATCHING_PATH).log().all().when().get().then().log().headers().extract();
verifyErrorReceived(response, EmptyMetadataErrorThrower.ERROR_NO_METADATA);
assertThat(response.asString()).doesNotContain("metadata");
}
use of io.restassured.response.ExtractableResponse in project riposte by Nike-Inc.
the class ServerAsynchronousProcessingComponentTest method sendServerRequest.
protected static 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();
assertEquals(200, statusCode);
return mapper.readValue(s, Map.class);
});
}
Aggregations