Additional escape characters (\) were added to the header in generated tests
Looks similar to: #851
Spring cloud contract plugin version: 2.2.3.RELEASE
Contract :
import static org.springframework.cloud.contract.spec.Contract.make
[
make {
request {
name("test")
method 'GET'
urlPath('/test')
}
response {
status OK()
body( "test": "\"escaped\"")
headers {
contentType('application/pdf')
header(contentDisposition(), "attachment; filename=\"test.pdf\"")
}
}
}
]
Generated test:
@Test
public void validate_test() throws Exception {
// given:
RequestSpecification request = given();
// when:
Response response = given().spec(request)
.get("/test");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("application/pdf.*");
assertThat(response.header("Content-Disposition")).isEqualTo("attachment; filename=\\\"test.pdf\\\"");
// and:
String responseBody = response.getBody().asString();
assertThat(responseBody).isEqualTo("{test=\"escaped\"}");
}
Note that the body is compiled correctly but the header Content-Disposition value has an additional \\ resulting in a test failure.
The compiled header should have been assertThat(response.header("Content-Disposition")).isEqualTo("attachment; filename=\"test.pdf\"");
Additional escape characters (
\) were added to the header in generated testsLooks similar to: #851
Spring cloud contract plugin version: 2.2.3.RELEASE
Contract :
Generated test:
Note that the body is compiled correctly but the header
Content-Dispositionvalue has an additional\\resulting in a test failure.The compiled header should have been
assertThat(response.header("Content-Disposition")).isEqualTo("attachment; filename=\"test.pdf\"");