Search in sources :

Example 21 with CookieStore

use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.

the class CookieStoreTest method shouldNotServeSecureCookiesForDefaultRetrievedHttpUriScheme.

// rfc6265#section-1 Cookies for a given host are shared  across all the ports on that host
private void shouldNotServeSecureCookiesForDefaultRetrievedHttpUriScheme() {
    CookieStore store = new ThreadSafeCookieStore();
    store.add(Uri.create("https://foo.org/moodle/"), ClientCookieDecoder.LAX.decode("cookie1=VALUE1; Path=/"));
    store.add(Uri.create("https://foo.org:443/moodle/login"), ClientCookieDecoder.LAX.decode("cookie1=VALUE2; Path=/"));
    store.add(Uri.create("https://foo.org:443/moodle/login"), ClientCookieDecoder.LAX.decode("cookie1=VALUE3; Path=/; Secure"));
    Uri uri = Uri.create("http://foo.org/moodle/login");
    assertTrue(store.get(uri).isEmpty());
}
Also used : CookieStore(org.asynchttpclient.cookie.CookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore) Uri(org.asynchttpclient.uri.Uri) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore)

Example 22 with CookieStore

use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.

the class CookieStoreTest method returnCookieWhenDomainMatchesAndPathIsChild.

private void returnCookieWhenDomainMatchesAndPathIsChild() {
    CookieStore store = new ThreadSafeCookieStore();
    store.add(Uri.create("http://www.foo.com/bar"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com; path=/bar"));
    assertTrue(store.get(Uri.create("http://www.foo.com/bar/baz")).size() == 1);
}
Also used : CookieStore(org.asynchttpclient.cookie.CookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore)

Example 23 with CookieStore

use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.

the class CookieStoreTest method returnCookieWhenItWasSetOnParentPath.

private void returnCookieWhenItWasSetOnParentPath() {
    CookieStore store = new ThreadSafeCookieStore();
    store.add(Uri.create("http://www.foo.com"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com; path=/bar"));
    assertTrue(store.get(Uri.create("http://www.foo.com/bar/baz")).size() == 1);
}
Also used : CookieStore(org.asynchttpclient.cookie.CookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore)

Example 24 with CookieStore

use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.

the class CookieStoreTest method dontReturnCookieForAnotherDomain.

private void dontReturnCookieForAnotherDomain() {
    CookieStore store = new ThreadSafeCookieStore();
    store.add(Uri.create("http://www.foo.com"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; path="));
    assertTrue(store.get(Uri.create("http://www.bar.com")).isEmpty());
}
Also used : CookieStore(org.asynchttpclient.cookie.CookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore)

Example 25 with CookieStore

use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.

the class CookieStoreTest method dontReturnCookieWhenDomainMatchesButPathIsParent.

private void dontReturnCookieWhenDomainMatchesButPathIsParent() {
    CookieStore store = new ThreadSafeCookieStore();
    store.add(Uri.create("http://www.foo.com/bar"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com; path=/bar"));
    assertTrue(store.get(Uri.create("http://www.foo.com")).isEmpty());
}
Also used : CookieStore(org.asynchttpclient.cookie.CookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore) ThreadSafeCookieStore(org.asynchttpclient.cookie.ThreadSafeCookieStore)

Aggregations

CookieStore (org.asynchttpclient.cookie.CookieStore)35 ThreadSafeCookieStore (org.asynchttpclient.cookie.ThreadSafeCookieStore)33 Uri (org.asynchttpclient.uri.Uri)17 Test (org.testng.annotations.Test)5 Cookie (io.netty.handler.codec.http.cookie.Cookie)4 Timer (io.netty.util.Timer)3 TimeUnit (java.util.concurrent.TimeUnit)3 CookieEvictionTask (org.asynchttpclient.cookie.CookieEvictionTask)3 Sets (com.google.common.collect.Sets)2 ClientCookieDecoder (io.netty.handler.codec.http.cookie.ClientCookieDecoder)2 ClientCookieEncoder (io.netty.handler.codec.http.cookie.ClientCookieEncoder)2 DefaultCookie (io.netty.handler.codec.http.cookie.DefaultCookie)2 Collection (java.util.Collection)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Assert.assertTrue (org.testng.Assert.assertTrue)2 AfterClass (org.testng.annotations.AfterClass)2 BeforeClass (org.testng.annotations.BeforeClass)2