Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D758118C05 for ; Wed, 15 Jul 2015 16:16:54 +0000 (UTC) Received: (qmail 79636 invoked by uid 500); 15 Jul 2015 16:16:54 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 79568 invoked by uid 500); 15 Jul 2015 16:16:54 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 79432 invoked by uid 99); 15 Jul 2015 16:16:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2015 16:16:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F3FBBE0F7C; Wed, 15 Jul 2015 16:16:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Date: Wed, 15 Jul 2015 16:16:53 -0000 Message-Id: <81715bf53a154c3c90940c0447ebc144@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cxf git commit: Adding WSDL retrieval tests when basic auth + digest auth is configured 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 Authored: Wed Jul 15 16:59:33 2015 +0100 Committer: Colm O hEigeartaigh 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); + } + } }