cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] cxf git commit: Adding WSDL retrieval tests when basic auth + digest auth is configured
Date Wed, 15 Jul 2015 16:21:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes e6c4083c0 -> 2949663e0


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/fa68d9fa
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fa68d9fa
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fa68d9fa

Branch: refs/heads/2.7.x-fixes
Commit: fa68d9faee196b0f7db2361485e01d139736adb5
Parents: e6c4083
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Jul 15 16:59:33 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Jul 15 17:17:18 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/fa68d9fa/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/fa68d9fa/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);
+        }
+    }
 }


Mime
View raw message