Search in sources :

Example 16 with Cookie

use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.

the class TestCookieCompatibilitySpec method testParseWithPathMismatch2.

public void testParseWithPathMismatch2() throws Exception {
    Header header = new Header("Set-Cookie", "cookie-name=cookie-value; path=/foobar");
    CookieSpec cookiespec = new CookieSpecBase();
    try {
        Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "/foo", false, header);
        fail("MalformedCookieException should have been thrown.");
    } catch (MalformedCookieException e) {
    // expected
    }
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 17 with Cookie

use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.

the class TestCookieCompatibilitySpec method testCookieMismatch4.

public void testCookieMismatch4() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie("host", "name", "value", "/foobar", null, true);
    assertFalse(cookiespec.match("host", 80, "/foobar/", false, cookie));
}
Also used : Cookie(org.apache.commons.httpclient.Cookie)

Example 18 with Cookie

use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.

the class TestCookieCompatibilitySpec method testParseAttributeNullPath.

public void testParseAttributeNullPath() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie();
    cookiespec.parseAttribute(new NameValuePair("path", null), cookie);
    assertEquals("/", cookie.getPath());
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) NameValuePair(org.apache.commons.httpclient.NameValuePair)

Example 19 with Cookie

use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.

the class TestCookieCompatibilitySpec method testParse3.

/**
 * Test parse with quoted text
 */
public void testParse3() throws Exception {
    String headerValue = "name=\"Doe, John\";version=1;max-age=600;secure;domain=.apache.org";
    Header header = new Header("set-cookie", headerValue);
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie[] cookies = cookieParse(cookiespec, "www.apache.org", 80, "/", false, header);
    assertEquals(1, cookies.length);
    assertEquals("name", cookies[0].getName());
    assertEquals("Doe, John", cookies[0].getValue());
    assertEquals(null, cookies[0].getComment());
    assertEquals(0, cookies[0].getVersion());
    assertEquals(".apache.org", cookies[0].getDomain());
    assertEquals("/", cookies[0].getPath());
    assertTrue(cookies[0].getSecure());
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 20 with Cookie

use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.

the class TestCookieCompatibilitySpec method testValidateBlankPath.

public void testValidateBlankPath() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie("host", "name", "value", "/", null, false);
    cookiespec.validate("host", 80, "   ", false, cookie);
}
Also used : Cookie(org.apache.commons.httpclient.Cookie)

Aggregations

Cookie (org.apache.commons.httpclient.Cookie)140 Header (org.apache.commons.httpclient.Header)69 NameValuePair (org.apache.commons.httpclient.NameValuePair)13 HttpState (org.apache.commons.httpclient.HttpState)11 HttpClient (org.apache.commons.httpclient.HttpClient)8 CookieSpec (org.apache.commons.httpclient.cookie.CookieSpec)8 Test (org.junit.jupiter.api.Test)8 GetMethod (org.apache.commons.httpclient.methods.GetMethod)6 ZMailbox (com.zimbra.client.ZMailbox)4 IOException (java.io.IOException)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 HttpException (org.apache.commons.httpclient.HttpException)4 Test (org.junit.Test)4 ZimbraCookie (com.zimbra.common.util.ZimbraCookie)3 Account (com.zimbra.cs.account.Account)3 Map (java.util.Map)3 URI (org.apache.commons.httpclient.URI)3 ApiException (org.zaproxy.zap.extension.api.ApiException)3 ZAuthToken (com.zimbra.common.auth.ZAuthToken)2