ReleaseNotes23
-
Improved SSL configuration. Fixed several regression bugs and allows for defining a trust store and a
SSLSocketFactory
. -
It's now much easier to connect to sites with invalid SSL certificates. All you have to do is to use the
relaxedHTTPSValidation
method. For example:given().relaxedHTTPSValidation().when().get("https://some_server.com"). ..
You can also define this statically for all requests:
RestAssured.useRelaxedHTTPSValidation();
or in a request specification.
-
Added support for authentication to RestAssuredMockMvc. You can now do e.g.
given().auth().principal(..). ..
Some authentication methods require Spring Security to be on the classpath (optional). It's also possible to define authentication statically:
RestAssuredMockMvc.authentication = principal("username", "password");
where the
principal
method is statically imported from RestAssuredMockMvc. It's also possible to define an authentication scheme in a request builder:MockMvcRequestSpecification spec = new MockMvcRequestSpecBuilder.setAuth(principal("username", "password")).build();
-
Added support for using data from a response to verify another part of the response. For example consider the following JSON document returned from service x:
{ "userId" : "some-id", "href" : "http://localhost:8080/some-id" }
You may notice that the "href" attribute ends with the value of the "userId" attribute. If we want to verify this we can implement a
com.jayway.restassured.matcher.ResponseAwareMatcher
and use it like this:get("/x").then().body("href", new ResponseAwareMatcher<Response>() { public Matcher<?> matcher(Response response) { return equalTo("http://localhost:8080/" + response.path("userId")); } });
There are some predefined matchers that you can use defined in the
com.jayway.restassured.matcher.RestAssuredMatchers
(orcom.jayway.restassured.module.mockmvc.matcher.RestAssuredMockMvcMatchers
if using the spring-mock-mvc module). For example:get("/x").then().body("href", endsWithPath("userId"));
ResponseAwareMatchers
can also be composed, either with anotherResponseAwareMatcher
or with a Hamcrest Matcher. For example:get("/x").then().body("href", endsWithPath("userId").and(startsWith("http:/localhost:8080/")));
-
The json-path module accidentally depended on faster-jackson, jackson, gson and simple-json and brought then in as transitive dependencies. This has now been resolved which means that these dependencies are optional as intended (issue 297).
-
Statically defined configuration (such as
RestAssured.config = ..
) is now automatically applied to RequestSpecBuilders in both RestAssured and RestAssuredMockMvc. To revert to previous behavior you can donew RequestSpecBuilder.config(newConfig()). .
See change log for more details.