Search in sources :

Example 21 with Cookie

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

the class TestCookieCompatibilitySpec method testInvalidMatchDomain.

public void testInvalidMatchDomain() throws Exception {
    Cookie cookie = new Cookie("beta.gamma.com", "name", null, "/", null, false);
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);
    CookieSpec cookiespec = new CookieSpecBase();
    cookiespec.validate("alpha.beta.gamma.com", 80, "/", false, cookie);
    assertTrue(cookiespec.match("alpha.beta.gamma.com", 80, "/", false, cookie));
}
Also used : Cookie(org.apache.commons.httpclient.Cookie)

Example 22 with Cookie

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

the class TestCookieCompatibilitySpec method testInvalidSecondDomainLevelCookieMatch2.

public void testInvalidSecondDomainLevelCookieMatch2() 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)

Example 23 with Cookie

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

the class TestCookieCompatibilitySpec method testParseAttributeUnknownValue.

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

Example 24 with Cookie

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

the class TestCookieCompatibilitySpec method testValidateBlankHost.

public void testValidateBlankHost() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie();
    try {
        cookiespec.validate("   ", 80, "/", false, cookie);
        fail("IllegalArgumentException must have been thrown");
    } catch (IllegalArgumentException expected) {
    }
}
Also used : Cookie(org.apache.commons.httpclient.Cookie)

Example 25 with Cookie

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

the class TestCookieCompatibilitySpec method testParseWithNullHostAndPath.

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

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