use of org.apache.http.cookie.CookieAttributeHandler in project lucene-solr by apache.
the class SolrPortAwareCookieSpecTest method testDomainValidate1.
@Test
public void testDomainValidate1() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();
cookie.setDomain("somehost");
h.validate(cookie, origin);
cookie.setDomain("otherhost");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
use of org.apache.http.cookie.CookieAttributeHandler in project lucene-solr by apache.
the class SolrPortAwareCookieSpecTest method testDomainMatch1.
@Test
public void testDomainMatch1() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();
cookie.setDomain(null);
Assert.assertFalse(h.match(cookie, origin));
cookie.setDomain(".somedomain.com");
Assert.assertTrue(h.match(cookie, origin));
}
use of org.apache.http.cookie.CookieAttributeHandler in project lucene-solr by apache.
the class SolrPortAwareCookieSpecTest method testDomainHostPortValidate.
@Test
public void testDomainHostPortValidate() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();
cookie.setDomain("somehost:80");
h.validate(cookie, origin);
cookie.setDomain("somehost:1234");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
use of org.apache.http.cookie.CookieAttributeHandler in project lucene-solr by apache.
the class SolrPortAwareCookieSpecTest method testDomainValidate2.
@Test
public void testDomainValidate2() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();
cookie.setDomain(".somedomain.com");
h.validate(cookie, origin);
cookie.setDomain(".otherdomain.com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
cookie.setDomain("www.otherdomain.com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
use of org.apache.http.cookie.CookieAttributeHandler in project lucene-solr by apache.
the class SolrPortAwareCookieSpecTest method testDomainValidate3.
@Test
public void testDomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();
cookie.setDomain(".a.com");
h.validate(cookie, origin);
cookie.setDomain(".com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
Aggregations