use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method handleMissingDomainAsRequestHost.
private void handleMissingDomainAsRequestHost() {
CookieStore store = new ThreadSafeCookieStore();
Uri uri = Uri.create("http://www.foo.com");
store.add(uri, ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Path=/"));
assertTrue(store.get(uri).size() == 1);
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method returnCookieWhenItWasSetOnSamePath.
private void returnCookieWhenItWasSetOnSamePath() {
CookieStore store = new ThreadSafeCookieStore();
store.add(Uri.create("http://www.foo.com"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; path=/bar/"));
assertTrue(store.get(Uri.create("http://www.foo.com/bar/")).size() == 1);
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method handleMultipleCookieOfSameNameOnDifferentPaths.
private void handleMultipleCookieOfSameNameOnDifferentPaths() {
CookieStore store = new ThreadSafeCookieStore();
store.add(Uri.create("http://www.foo.com"), ClientCookieDecoder.LAX.decode("cookie=VALUE0; path=/"));
store.add(Uri.create("http://www.foo.com/foo/bar"), ClientCookieDecoder.LAX.decode("cookie=VALUE1; path=/foo/bar/"));
store.add(Uri.create("http://www.foo.com/foo/baz"), ClientCookieDecoder.LAX.decode("cookie=VALUE2; path=/foo/baz/"));
Uri uri1 = Uri.create("http://www.foo.com/foo/bar/");
List<Cookie> cookies1 = store.get(uri1);
assertTrue(cookies1.size() == 2);
assertTrue(cookies1.stream().filter(c -> c.value().equals("VALUE0") || c.value().equals("VALUE1")).count() == 2);
Uri uri2 = Uri.create("http://www.foo.com/foo/baz/");
List<Cookie> cookies2 = store.get(uri2);
assertTrue(cookies2.size() == 2);
assertTrue(cookies2.stream().filter(c -> c.value().equals("VALUE0") || c.value().equals("VALUE2")).count() == 2);
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method returnMultipleCookiesEvenIfTheyHaveSameName.
private void returnMultipleCookiesEvenIfTheyHaveSameName() {
CookieStore store = new ThreadSafeCookieStore();
store.add(Uri.create("http://foo.com"), ClientCookieDecoder.LAX.decode("JSESSIONID=FOO; Domain=.foo.com"));
store.add(Uri.create("http://sub.foo.com"), ClientCookieDecoder.LAX.decode("JSESSIONID=BAR; Domain=sub.foo.com"));
Uri uri1 = Uri.create("http://sub.foo.com");
List<Cookie> cookies1 = store.get(uri1);
assertTrue(cookies1.size() == 2);
assertTrue(cookies1.stream().filter(c -> c.value().equals("FOO") || c.value().equals("BAR")).count() == 2);
List<String> encodedCookieStrings = cookies1.stream().map(ClientCookieEncoder.LAX::encode).collect(Collectors.toList());
assertTrue(encodedCookieStrings.contains("JSESSIONID=FOO"));
assertTrue(encodedCookieStrings.contains("JSESSIONID=BAR"));
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method handleTrailingSlashesInPaths.
private void handleTrailingSlashesInPaths() {
CookieStore store = new ThreadSafeCookieStore();
store.add(Uri.create("https://vagrant.moolb.com/app/consumer/j_spring_cas_security_check?ticket=ST-5-Q7gzqPpvG3N3Bb02bm3q-llinder-vagrantmgr.moolb.com"), ClientCookieDecoder.LAX.decode("JSESSIONID=211D17F016132BCBD31D9ABB31D90960; Path=/app/consumer/; HttpOnly"));
assertTrue(store.getAll().size() == 1);
assertTrue(store.get(Uri.create("https://vagrant.moolb.com/app/consumer/")).get(0).value().equals("211D17F016132BCBD31D9ABB31D90960"));
}
Aggregations