Search in sources :

Example 41 with Cookie

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

the class TestCookieCompatibilitySpec method testCookieNameStartingWithDollarSign.

/**
 * Tests if cookie constructor rejects cookie name starting with $.
 */
public void testCookieNameStartingWithDollarSign() throws Exception {
    Header setcookie = new Header("Set-Cookie", "$invalid_name=");
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "/", false, setcookie);
    assertNotNull(parsed);
    assertEquals(1, parsed.length);
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 42 with Cookie

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

the class TestCookieCompatibilitySpec method testMatchBlankPath.

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

Example 43 with Cookie

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

the class TestCookieCompatibilitySpec method testParseNoName.

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

Example 44 with Cookie

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

the class TestCookieCompatibilitySpec method testParseWithBlankPath.

public void testParseWithBlankPath() throws Exception {
    Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=127.0.0.1; path=/; secure");
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "  ", false, header);
    assertNotNull(parsed);
    assertEquals(1, parsed.length);
    assertEquals("/", parsed[0].getPath());
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 45 with Cookie

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

the class TestCookieCompatibilitySpec method testInvalidSecondDomainLevelCookieMatch1.

public void testInvalidSecondDomainLevelCookieMatch1() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false);
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);
    CookieSpec cookiespec = new CookieSpecBase();
    assertFalse(cookiespec.match("antisourceforge.net", 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