Search in sources :

Example 76 with Cookie

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

the class TestCookieCompatibilitySpec method testParseAttributeInvalidMaxAge.

public void testParseAttributeInvalidMaxAge() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie();
    try {
        cookiespec.parseAttribute(new NameValuePair("max-age", "crap"), 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 77 with Cookie

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

the class TestCookieCompatibilitySpec method testValidateNullHost.

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

Example 78 with Cookie

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

the class TestCookieCompatibilitySpec method testQuotedExpiresAttribute.

// see issue #5279
public void testQuotedExpiresAttribute() throws Exception {
    String headerValue = "custno=12345;Expires='Thu, 01-Jan-2070 00:00:10 GMT'";
    Header header = new Header("set-cookie", headerValue);
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie[] cookies = cookieParse(cookiespec, "www.apache.org", 80, "/", true, header);
    assertNotNull("Expected some cookies", cookies);
    assertEquals("Expected 1 cookie", 1, cookies.length);
    assertNotNull("Expected cookie to have getExpiryDate", cookies[0].getExpiryDate());
}
Also used : Cookie(org.apache.commons.httpclient.Cookie) Header(org.apache.commons.httpclient.Header)

Example 79 with Cookie

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

the class TestCookieCompatibilitySpec method testMatchNullCookiePath.

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

Example 80 with Cookie

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

the class TestCookieCompatibilitySpec method testCookieMatch4.

public void testCookieMatch4() throws Exception {
    CookieSpec cookiespec = new CookieSpecBase();
    Cookie cookie = new Cookie("host", "name", "value", "/", null, false);
    assertTrue(cookiespec.match("host", 80, "/foobar", 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