package contracts
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method 'GET'
url('/test')
headers {
accept(applicationJson())
header("X-Authorization", "eyJhbGciOiJIUzI1NiJ9.eyJtZW1iZXJObyI6IjEyMzQ1In0.VdYumw6QkfxaBgFUZNyza1VfNKiZ2WW4JaxIKe-G8HA")
}
}
response {
status OK()
body([
"test": "\"escaped\""
])
headers {
contentType(applicationJson())
}
}
}
results in:
@Test
public void validate_escapeDoubleQuotes() throws Exception {
// given:
MockMvcRequestSpecification request = given()
.header("Accept", "application/json")
.header("X-Authorization", "eyJhbGciOiJIUzI1NiJ9.eyJtZW1iZXJObyI6IjEyMzQ1In0.VdYumw6QkfxaBgFUZNyza1VfNKiZ2WW4JaxIKe-G8HA");
// when:
ResponseOptions response = given().spec(request)
.get("/test");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("application/json.*");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
assertThatJson(parsedJson).field("['test']").isEqualTo("\\"escaped\\"");
}
which doesn't compile. See example https://github.com/tunovic/contract-testing
Tried with 2.1.0.BUILD-SNAPSHOT and 2.0.3.BUILD-SNAPSHOT.
Maybe related to #169
results in:
which doesn't compile. See example https://github.com/tunovic/contract-testing
Tried with 2.1.0.BUILD-SNAPSHOT and 2.0.3.BUILD-SNAPSHOT.
Maybe related to #169