Search in sources :

Example 86 with CookieManager

use of java.net.CookieManager in project robovm by robovm.

the class CookiesTest method testNonMatchingDomainsRejected.

public void testNonMatchingDomainsRejected() throws Exception {
    TestCookieStore cookieStore = new TestCookieStore();
    CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
    cookieManager.put(new URI("http://android.com/"), cookieHeaders("a=android;domain=google.com"));
    assertEquals(Collections.<HttpCookie>emptyList(), cookieStore.cookies);
}
Also used : URI(java.net.URI) CookieManager(java.net.CookieManager)

Example 87 with CookieManager

use of java.net.CookieManager in project robovm by robovm.

the class CookiesTest method testCookieStoreUriKeepsHost.

public void testCookieStoreUriKeepsHost() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    cookieStore.add(new URI("http://b.com/"), new HttpCookie("a", "android"));
    assertEquals(Arrays.asList(new URI("http://b.com")), cookieStore.getURIs());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 88 with CookieManager

use of java.net.CookieManager in project robovm by robovm.

the class CookiesTest method testPathDefaulting.

public void testPathDefaulting() throws Exception {
    TestCookieStore cookieStore = new TestCookieStore();
    CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
    cookieManager.put(new URI("http://android.com/foo/bar"), cookieHeaders("a=android"));
    assertEquals("/foo/", cookieStore.getCookie("a").getPath());
    cookieManager.put(new URI("http://android.com/"), cookieHeaders("b=banana"));
    assertEquals("/", cookieStore.getCookie("b").getPath());
    cookieManager.put(new URI("http://android.com/foo/"), cookieHeaders("c=carrot"));
    assertEquals("/foo/", cookieStore.getCookie("c").getPath());
}
Also used : URI(java.net.URI) CookieManager(java.net.CookieManager)

Example 89 with CookieManager

use of java.net.CookieManager in project robovm by robovm.

the class CookiesTest method testCookieStoreUriDropsPort.

public void testCookieStoreUriDropsPort() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    cookieStore.add(new URI("http://a.com:443/"), new HttpCookie("a", "android"));
    assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 90 with CookieManager

use of java.net.CookieManager in project robovm by robovm.

the class CookiesTest method testCookieStoreUriDropsPath.

public void testCookieStoreUriDropsPath() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    cookieStore.add(new URI("http://a.com/a/"), new HttpCookie("a", "android"));
    assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Aggregations

CookieManager (java.net.CookieManager)94 HttpCookie (java.net.HttpCookie)53 URI (java.net.URI)50 CookieStore (java.net.CookieStore)28 Test (org.junit.Test)16 MockResponse (com.google.mockwebserver.MockResponse)14 MockWebServer (com.google.mockwebserver.MockWebServer)14 List (java.util.List)9 MockResponse (okhttp3.mockwebserver.MockResponse)9 ArrayList (java.util.ArrayList)7 MockWebServer (okhttp3.mockwebserver.MockWebServer)7 RecordedRequest (com.google.mockwebserver.RecordedRequest)6 IOException (java.io.IOException)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Project (com.kickstarter.models.Project)3 Headers (com.koushikdutta.async.http.Headers)3 OkHttpClient (okhttp3.OkHttpClient)3 RefTag (com.kickstarter.libs.RefTag)2