make sure we ignore cookies

This commit is contained in:
Athou
2023-12-18 15:09:04 +01:00
parent a30bf18102
commit 6c3895e60a
2 changed files with 23 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package com.commafeed.backend;
import java.io.IOException;
import java.net.http.HttpTimeoutException;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.http.HttpStatus;
@@ -137,4 +138,23 @@ class HttpGetterTest {
Assertions.assertThrows(NotModifiedException.class, () -> getter.getBinary(this.feedUrl, null, "78910", TIMEOUT));
}
@Test
void ignoreCookie() throws Exception {
AtomicInteger calls = new AtomicInteger();
this.mockServerClient.when(HttpRequest.request().withMethod("GET")).respond(req -> {
calls.incrementAndGet();
if (req.containsHeader(HttpHeaders.COOKIE)) {
throw new Exception("cookie should not be sent by the client");
}
return HttpResponse.response().withBody("ok").withHeader(HttpHeaders.SET_COOKIE, "foo=bar");
});
Assertions.assertDoesNotThrow(() -> getter.getBinary(this.feedUrl, TIMEOUT));
Assertions.assertDoesNotThrow(() -> getter.getBinary(this.feedUrl, TIMEOUT));
Assertions.assertEquals(2, calls.get());
}
}