Relax domain name checks in ResponseCookie

Closes gh-23924
This commit is contained in:
Rossen Stoyanchev
2019-11-06 16:17:41 +00:00
parent 2e4944198d
commit e0faaa4807
2 changed files with 26 additions and 1 deletions

View File

@@ -85,6 +85,31 @@ public class ResponseCookieTests {
});
}
@Test
public void domainChecks() {
Arrays.asList("abc", "abc.org", "abc-def.org", "abc3.org", ".abc.org")
.forEach(domain -> ResponseCookie.from("n", "v").domain(domain).build());
Arrays.asList("-abc.org", "abc.org.", "abc.org-", "-abc.org", "abc.org-")
.forEach(domain -> {
try {
ResponseCookie.from("n", "v").domain(domain).build();
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), Matchers.containsString("Invalid first/last char"));
}
});
Arrays.asList("abc..org", "abc.-org", "abc-.org")
.forEach(domain -> {
try {
ResponseCookie.from("n", "v").domain(domain).build();
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), Matchers.containsString("invalid cookie domain char"));
}
});
}
}