MockWebResponseBuilder defaults cookie domain
Previously MockWebResponseBuilder would use the cookie domain of the cookie received from MockMvc response. This caused problems because the cookie domain can be null, but HtmlUnit forbids a null domain. This commit defaults the domain of the cookie to the domain of the WebRequest. Issues SPR-14169
This commit is contained in:
@@ -119,6 +119,20 @@ public class MockWebResponseBuilderTests {
|
||||
assertThat(header.getValue(), endsWith(";secure;httpOnly"));
|
||||
}
|
||||
|
||||
// SPR-14169
|
||||
@Test
|
||||
public void buildResponseHeadersNullDomainDefaulted() throws Exception {
|
||||
Cookie cookie = new Cookie("cookieA", "valueA");
|
||||
this.response.addCookie(cookie);
|
||||
WebResponse webResponse = this.responseBuilder.build();
|
||||
|
||||
List<NameValuePair> responseHeaders = webResponse.getResponseHeaders();
|
||||
assertThat(responseHeaders.size(), equalTo(1));
|
||||
NameValuePair header = responseHeaders.get(0);
|
||||
assertThat(header.getName(), equalTo("Set-Cookie"));
|
||||
assertThat(header.getValue(), equalTo("cookieA=valueA"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildStatus() throws Exception {
|
||||
WebResponse webResponse = this.responseBuilder.build();
|
||||
|
||||
Reference in New Issue
Block a user