use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HttpConduitConfigurationTest method verifyConduit.
private void verifyConduit(HTTPConduit conduit) {
AuthorizationPolicy authp = conduit.getAuthorization();
assertNotNull(authp);
assertEquals("Betty", authp.getUserName());
assertEquals("password", authp.getPassword());
TLSClientParameters tlscps = conduit.getTlsClientParameters();
assertNotNull(tlscps);
assertTrue(tlscps.isDisableCNCheck());
assertEquals(3600000, tlscps.getSslCacheTimeout());
KeyManager[] kms = tlscps.getKeyManagers();
assertTrue(kms != null && kms.length == 1);
assertTrue(kms[0] instanceof X509KeyManager);
TrustManager[] tms = tlscps.getTrustManagers();
assertTrue(tms != null && tms.length == 1);
assertTrue(tms[0] instanceof X509TrustManager);
FiltersType csfs = tlscps.getCipherSuitesFilter();
assertNotNull(csfs);
assertEquals(1, csfs.getInclude().size());
assertEquals(1, csfs.getExclude().size());
HTTPClientPolicy clientPolicy = conduit.getClient();
assertEquals(10240, clientPolicy.getChunkLength());
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class ClientPolicyCalculatorTest method testCompatibleClientPolicies.
@Test
public void testCompatibleClientPolicies() {
ClientPolicyCalculator calc = new ClientPolicyCalculator();
HTTPClientPolicy p1 = new HTTPClientPolicy();
assertTrue("Policy is not compatible with itself.", calc.compatible(p1, p1));
HTTPClientPolicy p2 = new HTTPClientPolicy();
assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
p1.setBrowserType("browser");
assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
p1.setBrowserType(null);
p1.setConnectionTimeout(10000);
assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
p1.setAllowChunking(false);
p2.setAllowChunking(true);
assertFalse("Policies are compatible.", calc.compatible(p1, p2));
p2.setAllowChunking(false);
assertTrue("Policies are compatible.", calc.compatible(p1, p2));
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class ClientPolicyCalculatorTest method testLongTimeouts.
@Test
public void testLongTimeouts() {
ClientPolicyCalculator calc = new ClientPolicyCalculator();
HTTPClientPolicy p1 = new HTTPClientPolicy();
HTTPClientPolicy p2 = new HTTPClientPolicy();
p2.setReceiveTimeout(120000);
p2.setConnectionTimeout(60000);
HTTPClientPolicy p = calc.intersect(p1, p2);
assertEquals(120000, p.getReceiveTimeout());
assertEquals(60000, p.getConnectionTimeout());
p1 = new HTTPClientPolicy();
p2 = new HTTPClientPolicy();
p1.setReceiveTimeout(120000);
p1.setConnectionTimeout(60000);
p = calc.intersect(p1, p2);
assertEquals(120000, p.getReceiveTimeout());
assertEquals(60000, p.getConnectionTimeout());
p2.setReceiveTimeout(50000);
p2.setConnectionTimeout(20000);
p = calc.intersect(p1, p2);
// p1 should have priority
assertEquals(120000, p.getReceiveTimeout());
assertEquals(60000, p.getConnectionTimeout());
// reverse intersect
p = calc.intersect(p2, p1);
// p2 should have priority
assertEquals(50000, p.getReceiveTimeout());
assertEquals(20000, p.getConnectionTimeout());
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HTTPSConduitTest method testHttpsRedirectToHttpFail.
@Test
public void testHttpsRedirectToHttpFail() throws Exception {
startServer("Mortimer");
startServer("Poltim");
URL wsdl = getClass().getResource("greeting.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter poltim = service.getPort(poltimQ, Greeter.class);
assertNotNull("Port is null", poltim);
updateAddressPort(poltim, getPort("PORT2"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Client client = ClientProxy.getClient(poltim);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAutoRedirect(true);
http.setClient(httpClientPolicy);
http.setTlsClientParameters(tlsClientParameters);
configureProxy(client);
poltim.sayHi();
// client -> poltim is https and thus not recorded but then redirected to mortimer
// client -> mortimer is http and recoreded
assertProxyRequestCount(1);
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HTTPSConduitTest method verifyBethalClient.
// we just verify the configurations are loaded successfully
private void verifyBethalClient(Greeter bethal) {
Client client = ClientProxy.getClient(bethal);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = http.getClient();
assertTrue("the httpClientPolicy's autoRedirect should be true", httpClientPolicy.isAutoRedirect());
TLSClientParameters tlsParameters = http.getTlsClientParameters();
assertNotNull("the http conduit's tlsParameters should not be null", tlsParameters);
// If we set any name, but Edward, Mary, or George,
// and a password of "password" we will get through
// Bethal.
AuthorizationPolicy authPolicy = http.getAuthorization();
assertEquals("Set the wrong user name from the configuration", "Betty", authPolicy.getUserName());
assertEquals("Set the wrong pass word form the configuration", "password", authPolicy.getPassword());
configureProxy(ClientProxy.getClient(bethal));
String answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
assertTrue("Unexpected answer: " + answer, "Bonjour from Bethal".equals(answer));
// With HTTPS, it will just be a CONNECT to the proxy and all the
// data is encrypted. Thus, the proxy cannot distinquish the requests
assertProxyRequestCount(0);
}
Aggregations