REST Assured 2.1.0
Highlights
Section titled “Highlights”-
Introducing support for Json Schema validation. For example given the following schema located in the classpath as
products-schema.json:{"$schema": "http://json-schema.org/draft-04/schema#","title": "Product set","type": "array","items": {"title": "Product","type": "object","properties": {"id": {"description": "The unique identifier for a product","type": "number"},"name": {"type": "string"},"price": {"type": "number","minimum": 0,"exclusiveMinimum": true},"tags": {"type": "array","items": {"type": "string"},"minItems": 1,"uniqueItems": true},"dimensions": {"type": "object","properties": {"length": {"type": "number"},"width": {"type": "number"},"height": {"type": "number"}},"required": ["length", "width", "height"]},"warehouseLocation": {"description": "Coordinates of the warehouse with the product","$ref": "http://json-schema.org/geo"}},"required": ["id", "name", "price"]}}you can validate that a resource (
/products) conforms with the schema:get("/products").then().assertThat().body(matchesJsonSchemaInClasspath("products-schema.json"));matchesJsonSchemaInClasspathis statically imported fromcom.jayway.restassured.module.jsv.JsonSchemaValidatorand it’s recommended to statically import all methods from this class. However in order to use it you need to depend on thejson-schema-validatormodule by either downloading it from the download page or add the following dependency from Maven:<dependency><groupId>com.jayway.restassured</groupId><artifactId>json-schema-validator</artifactId><version>2.1.0</version></dependency> -
Added support to for mixing text and path assertions. For example:
get("/lotto").then().body(containsString("\"numbers\":[52")).and().body("lotto.winners.winnerId", hasItems(23, 54)); -
Added support for disabling hostname verification during certificate authentication by using the CertificateAuthSettings:
given().auth().certificate(certUrl, password, certAuthSettings().using().allowAllHostnames(). .. -
Added SSLConfig which allows you to better configure SSL configuration such as KeyStore and host name verification strategies. It’s also much simpler to allow all host names (when a server has a bad certificate specifying an invalid host name). Instead of having to create and import a KeyStore you can now do:
RestAssured.config = newConfig().sslConfig(sslConifg().allowAllHostnames());
Non-backward compatible changes
Section titled “Non-backward compatible changes”-
It’s no longer possible to assert that an empty response object has a path that is null, for example let’s say that the “/statusCode409WithNoBody” resource returns an empty body:
expect().contentType(ContentType.JSON).body("error", equalTo(null)).when().get("/statusCode409WithNoBody"); // This will now throw assertion error -
Changed default response content charset from ISO-8859-1 to system default charset. The reason for this that most users would probably expect the system default charset. To change the behaviour use the DecoderConfig.
-
Changed default request content charset from ISO-8859-1 to system default charset. The reason for this that most users would probably expect the system default charset. To change the behaviour use the EncoderConfig.
-
Removed the following methods from the RestAssured and AuthenticationSpecification API:
-
certificate(String certURL, String password, String certType, int port, KeystoreProvider trustStoreProvider)They are replaced by thecertificate(String certURL, String password, CertificateAuthSettings certificateAuthSettings)method. For example:RestAssured.authentication = certificate(certUrl, password, certAuthSettings().with().port(435));and:
given().auth().certificate(certUrl, password, certAuthSettings().with().port(435)). .. -
Removed static method “RestAssured.keystore()”. You can now get the keystore settings from the SSLConfig instead.
-
Removed the
com.jayway.restassured.authentication.KeyStoreProviderinterface. TheKeyStoreProviderwas actually NOT used to create a KeyStore but rather a trust store. To specify the trust store after this change use the SSLConfig or certificate authentication. -
All
keystorerelated methods in the RestAssured API now returnsvoidinstead ofKeyStoreSpec. -
Removed method “RestAssured.keyStore()”. If you want to get the configured “keystore” configuration you can now call “RestAssured.config().getSSLConfig();”.
Deprecations
Section titled “Deprecations”- Deprecated
RestAssured#certificate(String certURL, String password, String certType, int port) - Deprecated
AuthenticationSpecification#certificate(String certURL, String password, String certType, int port)
Minor changes
Section titled “Minor changes”See change log for more details.

