Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 02ec499af -> 0d3318d2c
Adding WSDL retrieval tests when basic auth + digest auth is configured Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/418a19b1 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/418a19b1 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/418a19b1 Branch: refs/heads/3.0.x-fixes Commit: 418a19b19851abeca31492bdf791a6bf0a8a360b Parents: 02ec499 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Wed Jul 15 16:59:33 2015 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Wed Jul 15 17:00:03 2015 +0100 ---------------------------------------------------------------------- .../systest/http_jetty/JettyBasicAuthTest.java | 35 ++++++++++++++++++-- .../systest/http_jetty/JettyDigestAuthTest.java | 33 ++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/418a19b1/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyBasicAuthTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyBasicAuthTest.java index 1839ba0..3072280 100644 --- a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyBasicAuthTest.java +++ b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyBasicAuthTest.java @@ -24,15 +24,21 @@ import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; +import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.bus.CXFBusFactory; +import org.apache.cxf.configuration.security.AuthorizationPolicy; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.apache.cxf.testutil.common.AbstractClientServerTestBase; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transport.http.HTTPConduitConfigurer; import org.apache.hello_world_soap_http.Greeter; import org.apache.hello_world_soap_http.SOAPService; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Test; /** * Tests thread pool config. @@ -64,8 +70,33 @@ public class JettyBasicAuthTest extends AbstractClientServerTestBase { bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd"); } - @Test + @org.junit.Test public void testBasicAuth() throws Exception { assertEquals("Hello Alice", greeter.greetMe("Alice")); } + + @org.junit.Test + public void testGetWSDL() throws Exception { + BusFactory bf = CXFBusFactory.newInstance(); + Bus bus = bf.createBus(); + bus.getInInterceptors().add(new LoggingInInterceptor()); + bus.getOutInterceptors().add(new LoggingOutInterceptor()); + + MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); + bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); + JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); + factory.createClient(ADDRESS + "?wsdl"); + } + + private static class MyHTTPConduitConfigurer implements HTTPConduitConfigurer { + public void configure(String name, String address, HTTPConduit c) { + + AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy(); + + authorizationPolicy.setUserName("ffang"); + authorizationPolicy.setPassword("pswd"); + authorizationPolicy.setAuthorizationType("Basic"); + c.setAuthorization(authorizationPolicy); + } + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/418a19b1/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java ---------------------------------------------------------------------- diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java index 11caafd..fe6e106 100644 --- a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java +++ b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/JettyDigestAuthTest.java @@ -28,18 +28,23 @@ import javax.xml.ws.Endpoint; import javax.xml.ws.WebServiceException; import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.bus.CXFBusFactory; import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.configuration.security.AuthorizationPolicy; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.interceptor.Fault; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.apache.cxf.message.Message; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; import org.apache.cxf.testutil.common.AbstractClientServerTestBase; import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transport.http.HTTPConduitConfigurer; import org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit; import org.apache.cxf.transport.http.auth.DigestAuthSupplier; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; @@ -47,7 +52,6 @@ import org.apache.hello_world_soap_http.Greeter; import org.apache.hello_world_soap_http.SOAPService; import org.apache.http.auth.Credentials; import org.apache.http.auth.UsernamePasswordCredentials; - import org.junit.BeforeClass; import org.junit.Test; @@ -147,7 +151,7 @@ public class JettyDigestAuthTest extends AbstractClientServerTestBase { //which async client can handle but we cannot. doTest(true); } - + private void doTest(boolean async) throws Exception { setupClient(async); assertEquals("Hello Alice", greeter.greetMe("Alice")); @@ -168,4 +172,29 @@ public class JettyDigestAuthTest extends AbstractClientServerTestBase { //ignore - expected } } + + @org.junit.Test + public void testGetWSDL() throws Exception { + BusFactory bf = CXFBusFactory.newInstance(); + Bus bus = bf.createBus(); + bus.getInInterceptors().add(new LoggingInInterceptor()); + bus.getOutInterceptors().add(new LoggingOutInterceptor()); + + MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); + bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); + JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); + factory.createClient(ADDRESS + "?wsdl"); + } + + private static class MyHTTPConduitConfigurer implements HTTPConduitConfigurer { + public void configure(String name, String address, HTTPConduit c) { + + AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy(); + + authorizationPolicy.setUserName("ffang"); + authorizationPolicy.setPassword("pswd"); + authorizationPolicy.setAuthorizationType("Digest"); + c.setAuthorization(authorizationPolicy); + } + } }