Filters headers from response for Groovy DSL creation from rest docs; fixes #455

This commit is contained in:
Marcin Grzejszczak
2017-11-13 10:16:29 +01:00
parent 05db1d0933
commit 0097b6db6e
2 changed files with 5 additions and 2 deletions

View File

@@ -73,9 +73,10 @@ public class ContractDslSnippet extends TemplatedSnippet {
model.put("response_status", response.getStatus().value());
model.put("response_body_present", response.getContent().length > 0);
model.put("response_body", response.getContentAsString());
HttpHeaders headers = response.getHeaders();
Map<String, String> headers = response.getHeaders().toSingleValueMap();
filterHeaders(headers);
model.put("response_headers_present", !headers.isEmpty());
model.put("response_headers", headers.toSingleValueMap().entrySet());
model.put("response_headers", headers.entrySet());
@SuppressWarnings("unchecked") Set<String> jsonPaths = (Set<String>) operation.getAttributes()
.get("contract.jsonPaths");
model.put("response_json_paths_present", jsonPaths != null && !jsonPaths.isEmpty());

View File

@@ -87,6 +87,8 @@ public class ContractDslSnippetTests {
then(parsedContract.getRequest().getHeaders().getEntries()).isNotNull();
then(headerNames(parsedContract.getRequest().getHeaders().getEntries())).doesNotContain
(HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH);
then(headerNames(parsedContract.getResponse().getHeaders().getEntries())).doesNotContain
(HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH);
then(parsedContract.getRequest().getMethod().getClientValue()).isNotNull();
then(parsedContract.getRequest().getUrl().getClientValue()).isNotNull();
then(parsedContract.getRequest().getUrl().getClientValue().toString()).startsWith("/");