[cxf] branch 3.2.x-fixes updated (1af35ae -> 9d9dc38)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch 3.2.x-fixes updated (1af35ae -> 9d9dc38)

reta
This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 1af35ae  [maven-release-plugin] prepare for next development iteration
     new ba49650  Adding JAX-WS integration test for DefaultBasicAuthSupplier
     new 9d9dc38  Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  2 +
 .../cxf/systest/jaxws/JaxwsAsyncFailOverTest.java  |  6 ++
 ...ncFailOverTest.java => JaxwsBasicAuthTest.java} | 88 +++++++++++++++-------
 3 files changed, 67 insertions(+), 29 deletions(-)
 copy systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/{JaxwsAsyncFailOverTest.java => JaxwsBasicAuthTest.java} (51%)

Reply | Threaded
Open this post in threaded view
|

[cxf] 01/02: Adding JAX-WS integration test for DefaultBasicAuthSupplier

reta
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit ba496503a02ea81dbfc5a7268e4f89a720b69f0c
Author: reta <[hidden email]>
AuthorDate: Sun Jun 28 11:35:28 2020 -0400

    Adding JAX-WS integration test for DefaultBasicAuthSupplier
   
    (cherry picked from commit 7a13bfff60babe60ebfcdb45b5838eee6947e191)
    (cherry picked from commit 1c67d067ec967b907f56e1c5e0c268dc73452300)
---
 .../cxf/systest/jaxws/JaxwsAsyncFailOverTest.java  |  6 ++
 ...ncFailOverTest.java => JaxwsBasicAuthTest.java} | 88 +++++++++++++++-------
 2 files changed, 65 insertions(+), 29 deletions(-)

diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
index f9dc6b5..c04dc89 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
@@ -34,6 +34,7 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -77,6 +78,11 @@ public class JaxwsAsyncFailOverTest  extends AbstractBusClientServerTestBase {
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
 
+    @AfterClass
+    public static void stopServers() throws Exception {
+        stopAllServers();
+    }
+
     @Test
     public void testUseFailOverOnClient() throws Exception {
         List<String> serviceList = new ArrayList<>();
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsBasicAuthTest.java
similarity index 51%
copy from systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
copy to systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsBasicAuthTest.java
index f9dc6b5..0a24474 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsBasicAuthTest.java
@@ -19,27 +19,37 @@
 
 package org.apache.cxf.systest.jaxws;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
+import javax.annotation.Resource;
 import javax.jws.WebService;
-import javax.xml.ws.Response;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
 
-import org.apache.cxf.clustering.FailoverFeature;
-import org.apache.cxf.clustering.RandomStrategy;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.greeter_control.AbstractGreeterImpl;
 import org.apache.cxf.greeter_control.Greeter;
-import org.apache.cxf.greeter_control.types.GreetMeResponse;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier;
 
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class JaxwsAsyncFailOverTest  extends AbstractBusClientServerTestBase {
-    static final String PORT = allocatePort(ServerNoBodyParts.class, 1);
-    static final String PORT2 = allocatePort(ServerNoBodyParts.class, 2);
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class JaxwsBasicAuthTest extends AbstractBusClientServerTestBase {
+    static final String PORT = allocatePort(JaxwsBasicAuthTest.class);
 
     public static class Server extends AbstractBusTestServerBase {
 
@@ -62,12 +72,34 @@ public class JaxwsAsyncFailOverTest  extends AbstractBusClientServerTestBase {
             }
         }
 
-        @WebService(serviceName = "BasicGreeterService",
+        @WebService(serviceName = "ProtectedGreeterService",
                     portName = "GreeterPort",
                     endpointInterface = "org.apache.cxf.greeter_control.Greeter",
                     targetNamespace = "http://cxf.apache.org/greeter_control",
                     wsdlLocation = "testutils/greeter_control.wsdl")
         public class GreeterImpl extends AbstractGreeterImpl {
+            @Resource private WebServiceContext context;
+            
+            @Override
+            public String greetMe(String arg) {
+                final MessageContext messageContext = context.getMessageContext();
+                
+                final Map<String, List<String>> headers =
+                    CastUtils.cast((Map<?, ?>)messageContext.get(MessageContext.HTTP_REQUEST_HEADERS));
+
+                if (headers == null) {
+                    throw new WebServiceException("Not authorized");
+                }
+
+                final String authorization = headers.get("Authorization").get(0);
+                final String expected = DefaultBasicAuthSupplier.getBasicAuthHeader("user", "test", true);
+                
+                if (!expected.equals(authorization)) {
+                    throw new WebServiceException("Not authorized");
+                }
+
+                return "CXF is protected: " + arg;
+            }
         }
     }
 
@@ -76,34 +108,32 @@ public class JaxwsAsyncFailOverTest  extends AbstractBusClientServerTestBase {
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
+    
+    @AfterClass
+    public static void stopServers() throws Exception {
+        stopAllServers();
+    }
 
     @Test
-    public void testUseFailOverOnClient() throws Exception {
-        List<String> serviceList = new ArrayList<>();
-        serviceList.add("http://localhost:" + PORT + "/SoapContext/GreeterPort");
-
-        RandomStrategy strategy = new RandomStrategy();
-        strategy.setAlternateAddresses(serviceList);
-
-        FailoverFeature ff = new FailoverFeature();
-        ff.setStrategy(strategy);
-
+    public void testUseBasicAuthFromClient() throws Exception {
         // setup the feature by using JAXWS front-end API
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
         // set a fake address to kick off the failover feature
-        factory.setAddress("http://localhost:" + PORT2 + "/SoapContext/GreeterPort");
-        factory.getFeatures().add(ff);
+        factory.setAddress("http://localhost:" + PORT + "/SoapContext/GreeterPort");
         factory.setServiceClass(Greeter.class);
         Greeter proxy = factory.create(Greeter.class);
 
-        Response<GreetMeResponse>  response = proxy.greetMeAsync("cxf");
-        int waitCount = 0;
-        while (!response.isDone() && waitCount < 15) {
-            Thread.sleep(1000);
-            waitCount++;
-        }
-        assertTrue("Response still not received.", response.isDone());
-
+        Client clientProxy = ClientProxy.getClient(proxy);
+        HTTPConduit conduit = (HTTPConduit) clientProxy.getConduit();
+        conduit.getAuthorization().setAuthorizationType("Basic");
+        conduit.getAuthorization().setUserName("user");
+        conduit.getAuthorization().setPassword("test");
+        
+        final BindingProvider bindingProvider = (BindingProvider) proxy;
+        bindingProvider.getRequestContext().put("encode.basicauth.with.iso8859", true);
+
+        String response = proxy.greetMe("cxf");
+        assertThat("CXF is protected: cxf", equalTo(response));
     }
 
 }

Reply | Threaded
Open this post in threaded view
|

[cxf] 02/02: Recording .gitmergeinfo Changes

reta
In reply to this post by reta
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 9d9dc38550e72491de664456e43f2638a6d7f227
Author: reta <[hidden email]>
AuthorDate: Sun Jun 28 13:33:53 2020 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 11c1143..399ae05 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -26,6 +26,7 @@ B 04b232d262b54f1cfa92d891f97adfe5e50d5930
 B 055a2ec152d9945b0817c2fac82af43d0692bfd5
 B 057f4dc521f02227d7b36bbb508835a9edb69e15
 B 0623b2f923443330c7206932475e240d88fc4f2d
+B 066e10a27577e1d557e18159a7401e2f5753d842
 B 07251d65ed30455dd982fdbe694aab419d2fbfcb
 B 07696f88f3d5bae43c4a248c26fdf24a916fd5f5
 B 07faf9e4b03a2e15d9aa7885dacc63d1797df38f
@@ -1127,6 +1128,7 @@ M eb0855b8613823682cf267e1de457b8670be9b7b
 M eda37b0df9af9df3df8378c744900b75cbbac6e5
 M ee94d2d2d5a39836ef94f74892ccec2212411e6a
 M eeae6cde0faedd144a8cb5bdcd21326f7dc6056b
+M ef67a7f64ee1dd84c84a2cef86e73dd9ad7bb112
 M efb2c3082fe8799a9d90a696e31239551b4f1823
 M f044a02831ad2adff59155924682f73ffdf6213a
 M f09ae1ed3bbc88a6d7860697dd65821fd9958d99