use of io.restassured.response.Response in project vertx-openshift-it by cescoffier.
the class CircuitBreakerIT method testCircuitBreakerState.
private boolean testCircuitBreakerState(CircuitBreakerState expectedState) {
Response response = circuitBreakerResponse();
response.then().statusCode(200);
return response.getBody().asString().contains(expectedState.name());
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class JSONGetITest method supportsGettingResponseBodyWhenStatusCodeIs401.
@SuppressWarnings("unchecked")
@Test
public void supportsGettingResponseBodyWhenStatusCodeIs401() throws Exception {
final Response response = get("/secured/hello");
assertThat(response.getBody().asString(), allOf(containsString("401"), containsString("Unauthorized")));
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class URLEncodingITest method doesntDoubleEncodeParamsWhenDefiningUrlEncodingToTrue.
@Test
public void doesntDoubleEncodeParamsWhenDefiningUrlEncodingToTrue() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().urlEncodingEnabled(true).pathParam("pathParam", "path/param").formParam("formParam", "form/param").filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
/*
* Note that Scalatra cannot handle request with path parameters containing "/" (like path/param) even though it's URL encoded.
* Scalatra decodes the path prior to finding the method to invoke and thus we'll get an error back (since no resource mapping to /path/param/manyParams exist).
*/
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).then().body(equalTo("changed")).when().post("/{pathParam}/manyParams?queryParam=query/param");
assertThat(loggedRequestPathIn(writer), equalTo("http://localhost:8080/path%2Fparam/manyParams?queryParam=query%2Fparam"));
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class URLITest method get_request_with_form_parameters_as_map_that_contains_collection_as_one_of_parameters.
/**
* This test try to add form parameters as map that contains value as {@link Collection}
* @throws Exception
*/
@Test
public void get_request_with_form_parameters_as_map_that_contains_collection_as_one_of_parameters() throws Exception {
final List parameterValues = new ArrayList<String>() {
{
add("value1");
add("value2");
}
};
Map<String, Object> formParameters = new HashMap<String, Object>() {
{
put("list", parameterValues);
}
};
Response response = given().formParams(formParameters).when().post("/multiValueParam");
// Convert returned value to list
List<String> paramListFromResponse = Arrays.asList(response.jsonPath().getString("list").split(","));
Assert.assertEquals(parameterValues, paramListFromResponse);
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class OAuthITest method oauth2_works_with_non_preemptive_header_signing.
@Test
public void oauth2_works_with_non_preemptive_header_signing() {
final String accessToken = "accessToken";
given().auth().oauth2(accessToken).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
AuthenticationScheme scheme = requestSpec.getAuthenticationScheme();
assertThat(scheme, instanceOf(PreemptiveOAuth2HeaderScheme.class));
assertThat(((PreemptiveOAuth2HeaderScheme) scheme).getAccessToken(), equalTo(accessToken));
return new ResponseBuilder().setBody("ok").setStatusCode(200).build();
}
}).when().get("/somewhere").then().statusCode(200);
}
Aggregations