Skip to content

Commit

Permalink
document some apache behavior of the CookieStore
Browse files Browse the repository at this point in the history
  • Loading branch information
ryber committed Dec 9, 2020
1 parent eb8bac4 commit 5422e60
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion unirest/src/test/java/BehaviorTests/CookieTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ void stringCookieParsing() {
r3.getBody().assertNoCookie("color");
}

@Test // documenting Apache specific behavior we may not want moving forward.
void cannotOverrideManagedCookies() {
MockServer.expectCookie("foo", "bar");
HttpResponse r1 = Unirest.get(MockServer.GET).asEmpty();
assertEquals("bar", r1.getCookies().getNamed("foo").getValue());

MockServer.clearCookies();
Unirest.get(MockServer.GET)
.cookie("foo","baz")
.asObject(RequestCapture.class)
.getBody()
.assertCookie("foo","bar");
}

@Test
void newAgeCookies() {
Unirest.config().cookieSpec("standard");
Expand All @@ -253,7 +267,6 @@ void newAgeCookies() {
assertNotNull(response.getCookies().getNamed("cookie_name"));
HttpResponse<RequestCapture> r2 = Unirest.get(MockServer.GET).asObject(RequestCapture.class);
r2.getBody().assertCookie("cookie_name","blah");

}

private String getCookieValue(ZonedDateTime dt) {
Expand Down

0 comments on commit 5422e60

Please sign in to comment.