cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1543074 - in /cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws: parts/PartsTest.java swa/SWAPolicyTest.java
Date Mon, 18 Nov 2013 16:41:15 GMT
Author: coheigea
Date: Mon Nov 18 16:41:15 2013
New Revision: 1543074

URL: http://svn.apache.org/r1543074
Log:
Adding more @Ignore'd SWA tests

Modified:
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java?rev=1543074&r1=1543073&r2=1543074&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
Mon Nov 18 16:41:15 2013
@@ -22,12 +22,14 @@ package org.apache.cxf.systest.ws.parts;
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.ws.common.SecurityTestUtil;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 import org.example.contract.doubleit.DoubleItSwaPortType;
 import org.example.schema.doubleit.DoubleIt3;
@@ -486,8 +488,10 @@ public class PartsTest extends AbstractB
         port.doubleIt3(doubleIt, "12345".getBytes());
         
         // Streaming
-        // SecurityTestUtil.enableStreaming(port);
-        // port.doubleIt(25);
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
         
         // This should fail, as the service requires that the Attachments must be signed
         portQName = new QName(NAMESPACE, "DoubleItSignedAttachmentsPort2");
@@ -504,17 +508,18 @@ public class PartsTest extends AbstractB
             String error = "SignedParts";
             assertTrue(ex.getMessage().contains(error));
         }
-        /*
+        
         // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
-            port.doubleIt(25);
-            fail("Failure expected on a body which isn't signed");
+            enableStreaming(port);
+            doubleIt = new DoubleIt3();
+            doubleIt.setNumberToDouble(25);
+            port.doubleIt3(doubleIt, "12345".getBytes());
+            fail("Failure expected on an attachment which isn't signed");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             // String error = "SignedParts";
             // assertTrue(ex.getMessage().contains(error));
         }
-        */
         
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
@@ -546,8 +551,10 @@ public class PartsTest extends AbstractB
         port.doubleIt3(doubleIt, "12345".getBytes());
         
         // Streaming
-        // SecurityTestUtil.enableStreaming(port);
-        // port.doubleIt(25);
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
         
         // This should fail, as the service requires that the Attachments must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItEncryptedAttachmentsPort2");
@@ -564,20 +571,30 @@ public class PartsTest extends AbstractB
             String error = "EncryptedParts";
             assertTrue(ex.getMessage().contains(error));
         }
-        /*
+        
         // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
-            port.doubleIt(25);
-            fail("Failure expected on a body which isn't signed");
+            enableStreaming(port);
+            doubleIt = new DoubleIt3();
+            doubleIt.setNumberToDouble(25);
+            port.doubleIt3(doubleIt, "12345".getBytes());
+            fail("Failure expected on an attachment which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             // String error = "SignedParts";
             // assertTrue(ex.getMessage().contains(error));
         }
-        */
         
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
+    
+    static void enableStreaming(DoubleItSwaPortType port) {
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)port).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+    }
   
 }

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java?rev=1543074&r1=1543073&r2=1543074&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java
Mon Nov 18 16:41:15 2013
@@ -22,18 +22,22 @@ package org.apache.cxf.systest.ws.swa;
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.ws.common.SecurityTestUtil;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItSwaPortType;
 import org.example.schema.doubleit.DoubleIt3;
 import org.junit.BeforeClass;
 
 /**
- * A set of tests for the SwA specification (SOAP with Attachments) via WS-SecurityPolicy
+ * A set of tests for the SwA specification (SOAP with Attachments) via WS-SecurityPolicy.
+ * 
+ * It tests both DOM + StAX clients against the DOM server
  */
 //TODO Wait until we move off the WSS4J 2.0 beta release
 @org.junit.Ignore
@@ -60,7 +64,7 @@ public class SWAPolicyTest extends Abstr
     }
 
     @org.junit.Test
-    public void testSWASignatureContentAction() throws Exception {
+    public void testSWASignatureContentPolicy() throws Exception {
 
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = SWAPolicyTest.class.getResource("policy-client.xml");
@@ -76,10 +80,17 @@ public class SWAPolicyTest extends Abstr
                 service.getPort(portQName, DoubleItSwaPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
+        // Streaming
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -101,10 +112,17 @@ public class SWAPolicyTest extends Abstr
                 service.getPort(portQName, DoubleItSwaPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
+        // Streaming
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -126,10 +144,17 @@ public class SWAPolicyTest extends Abstr
                 service.getPort(portQName, DoubleItSwaPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
+        // Streaming
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -151,10 +176,17 @@ public class SWAPolicyTest extends Abstr
                 service.getPort(portQName, DoubleItSwaPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
+        // Streaming
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -176,11 +208,28 @@ public class SWAPolicyTest extends Abstr
                 service.getPort(portQName, DoubleItSwaPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
+        // Streaming
+        enableStreaming(port);
+        doubleIt = new DoubleIt3();
+        doubleIt.setNumberToDouble(25);
+        port.doubleIt3(doubleIt, "12345".getBytes());
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
+    
+    static void enableStreaming(DoubleItSwaPortType port) {
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)port).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+    }
+    
 }



Mime
View raw message