Search in sources :

Example 96 with Cookie

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

the class TestCookieCompatibilitySpec method testParseAttributeNullMaxAge.

public void testParseAttributeNullMaxAge() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie();
    try {
        cookiespec.parseAttribute(new NameValuePair("max-age", null), cookie);
        fail("MalformedCookieException must have been thrown");
    } catch (MalformedCookieException expected) {
    }
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) NameValuePair(org.apache.commons.httpclient.NameValuePair)

Example 97 with Cookie

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

the class TestCookieCompatibilitySpec method testParse1.

/**
 * Test basic parse (with various spacings
 */
public void testParse1() throws Exception {
    String headerValue = "custno = 12345; comment=test; version=1," + " name=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(2, cookies.length);
    assertEquals("custno", cookies[0].getName());
    assertEquals("12345", cookies[0].getValue());
    assertEquals("test", cookies[0].getComment());
    assertEquals(0, cookies[0].getVersion());
    assertEquals("www.apache.org", cookies[0].getDomain());
    assertEquals("/", cookies[0].getPath());
    assertFalse(cookies[0].getSecure());
    assertEquals("name", cookies[1].getName());
    assertEquals("John", cookies[1].getValue());
    assertEquals(null, cookies[1].getComment());
    assertEquals(0, cookies[1].getVersion());
    assertEquals(".apache.org", cookies[1].getDomain());
    assertEquals("/", cookies[1].getPath());
    assertTrue(cookies[1].getSecure());
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 98 with Cookie

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

the class TestCookieCompatibilitySpec method testCookieMismatch6.

public void testCookieMismatch6() 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 99 with Cookie

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

the class TestCookieCompatibilitySpec method testParseWithNegativePort.

public void testParseWithNegativePort() 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, "127.0.0.1", -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)

Example 100 with Cookie

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

the class TestCookieCompatibilitySpec method testCookieMatch1.

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

Aggregations

Cookie (org.apache.commons.httpclient.Cookie)136 Header (org.apache.commons.httpclient.Header)69 NameValuePair (org.apache.commons.httpclient.NameValuePair)13 CookieSpec (org.apache.commons.httpclient.cookie.CookieSpec)8 Test (org.junit.jupiter.api.Test)8 HttpState (org.apache.commons.httpclient.HttpState)5 HashMap (java.util.HashMap)4 HttpException (org.apache.commons.httpclient.HttpException)4 URI (org.apache.commons.httpclient.URI)3 ApiException (org.zaproxy.zap.extension.api.ApiException)3 ZimbraCookie (com.zimbra.common.util.ZimbraCookie)2 IOException (java.io.IOException)2 Date (java.util.Date)2 StringTokenizer (java.util.StringTokenizer)2 JSONException (net.sf.json.JSONException)2 JSONObject (net.sf.json.JSONObject)2 HttpClient (org.apache.commons.httpclient.HttpClient)2 URIException (org.apache.commons.httpclient.URIException)2 WSSecurityException (com.ibm.websphere.security.WSSecurityException)1 CredentialDestroyedException (com.ibm.websphere.security.auth.CredentialDestroyedException)1