cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1533398 - in /cxf/trunk/systests/ws-security/src/test: java/org/apache/cxf/systest/ws/parts/ resources/org/apache/cxf/systest/ws/parts/
Date Fri, 18 Oct 2013 11:35:08 GMT
Author: coheigea
Date: Fri Oct 18 11:35:08 2013
New Revision: 1533398

URL: http://svn.apache.org/r1533398
Log:
Added more 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/parts/StaxPartsTest.java
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/bad-req-elements-policy.xml
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/content-encrypted-elements-policy.xml
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/encrypted-elements-policy.xml
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/req-elements-policy.xml
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/signed-elements-policy.xml

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=1533398&r1=1533397&r2=1533398&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
Fri Oct 18 11:35:08 2013
@@ -129,6 +129,12 @@ public class PartsTest extends AbstractB
         QName portQName = new QName(NAMESPACE, "DoubleItRequiredElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires a (bad) header
@@ -136,6 +142,7 @@ public class PartsTest extends AbstractB
         port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         try {
             port.doubleIt(25);
             fail("Failure expected on a required header which isn't present");
@@ -144,6 +151,16 @@ public class PartsTest extends AbstractB
             assertTrue(ex.getMessage().contains(error));
         }
         
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a required header which isn't present");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "RequiredElements: No header element";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -242,6 +259,12 @@ public class PartsTest extends AbstractB
         QName portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the To header must be signed
@@ -249,6 +272,7 @@ public class PartsTest extends AbstractB
         port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         try {
             port.doubleIt(25);
             fail("Failure expected on a header which isn't signed");
@@ -257,6 +281,16 @@ public class PartsTest extends AbstractB
             assertTrue(ex.getMessage().contains(error));
         }
         
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't signed");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "SignedElements";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -355,6 +389,12 @@ public class PartsTest extends AbstractB
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the header must be encrypted
@@ -362,6 +402,7 @@ public class PartsTest extends AbstractB
         port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
         
+        // DOM
         try {
             port.doubleIt(25);
             fail("Failure expected on a header which isn't encrypted");
@@ -370,6 +411,16 @@ public class PartsTest extends AbstractB
             assertTrue(ex.getMessage().contains(error));
         }
         
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't encrypted");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "EncryptedElements";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -391,7 +442,6 @@ public class PartsTest extends AbstractB
         QName portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(port, PORT);
-        port.doubleIt(25);
         
         // This should fail, as the service requires that the header must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort2");

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/StaxPartsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/StaxPartsTest.java?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/StaxPartsTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/StaxPartsTest.java
Fri Oct 18 11:35:08 2013
@@ -28,9 +28,7 @@ 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.example.contract.doubleit.DoubleItPortType;
-
 import org.junit.BeforeClass;
 
 /**
@@ -113,6 +111,59 @@ public class StaxPartsTest extends Abstr
     }
     
     @org.junit.Test
+    public void testRequiredElements() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = PartsTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+       
+        // Successful invocation
+        QName portQName = new QName(NAMESPACE, "DoubleItRequiredElementsPort");
+        DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
+        port.doubleIt(25);
+        
+        // This should fail, as the service requires a (bad) header
+        portQName = new QName(NAMESPACE, "DoubleItRequiredElementsPort2");
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // DOM
+        try {
+            port.doubleIt(25);
+            fail("Failure expected on a required header which isn't present");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "ToTo must be present";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a required header which isn't present");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "ToTo must be present";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
     public void testSignedParts() throws Exception {
 
         SpringBusFactory bf = new SpringBusFactory();
@@ -190,6 +241,61 @@ public class StaxPartsTest extends Abstr
     }
     
     @org.junit.Test
+    public void testSignedElements() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = PartsTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+       
+        // Successful invocation
+        QName portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort");
+        DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
+        port.doubleIt(25);
+        
+        // This should fail, as the service requires that the To header must be signed
+        portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort2");
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // DOM
+        /* TODO See WSS-482
+        try {
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't signed");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "SignedElements";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't signed");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "SignedElements";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        */
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
     public void testEncryptedParts() throws Exception {
 
         SpringBusFactory bf = new SpringBusFactory();
@@ -266,4 +372,97 @@ public class StaxPartsTest extends Abstr
         bus.shutdown(true);
     }
     
+    @org.junit.Test
+    public void testEncryptedElements() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = PartsTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+       
+        // Successful invocation
+        QName portQName = new QName(NAMESPACE, "DoubleItEncryptedElementsPort");
+        DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // DOM
+        port.doubleIt(25);
+        
+        // Streaming
+        SecurityTestUtil.enableStreaming(port);
+        port.doubleIt(25);
+        
+        // This should fail, as the service requires that the header must be encrypted
+        portQName = new QName(NAMESPACE, "DoubleItEncryptedElementsPort2");
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        /*
+         * TODO See WSS-482
+        // DOM
+        try {
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't encrypted");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            System.out.println("ERR2: " + ex.getMessage());
+            String error = "EncryptedElements";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        
+        // Streaming
+        try {
+            SecurityTestUtil.enableStreaming(port);
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't encrypted");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // String error = "EncryptedElements";
+            // assertTrue(ex.getMessage().contains(error));
+        }
+        */
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
+    public void testContentEncryptedElements() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = PartsTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+       
+        // Successful invocation
+        QName portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort");
+        DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        // This should fail, as the service requires that the header must be encrypted
+        portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort2");
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        
+        try {
+            port.doubleIt(25);
+            fail("Failure expected on a header which isn't encrypted");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "To must be encrypted";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+
+    
 }

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/bad-req-elements-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/bad-req-elements-policy.xml?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/bad-req-elements-policy.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/bad-req-elements-policy.xml
Fri Oct 18 11:35:08 2013
@@ -41,7 +41,9 @@
                 </sp:AsymmetricBinding>
                 <sp:RequiredElements
                       xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
-                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing">wsa:ToTo</sp:XPath>
+                     <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+                        >/soap:Envelope/soap:Header/wsa:ToTo</sp:XPath>
                 </sp:RequiredElements>
                 <sp:SignedParts
                     xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/content-encrypted-elements-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/content-encrypted-elements-policy.xml?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/content-encrypted-elements-policy.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/content-encrypted-elements-policy.xml
Fri Oct 18 11:35:08 2013
@@ -41,7 +41,9 @@
                 </sp:AsymmetricBinding>
                 <sp:ContentEncryptedElements
                       xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
-                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing">//wsa:To</sp:XPath>
+                     <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+                        >/soap:Envelope/soap:Header/wsa:To</sp:XPath>
                 </sp:ContentEncryptedElements>
                 <sp:SignedParts
                     xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/encrypted-elements-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/encrypted-elements-policy.xml?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/encrypted-elements-policy.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/encrypted-elements-policy.xml
Fri Oct 18 11:35:08 2013
@@ -41,7 +41,9 @@
                 </sp:AsymmetricBinding>
                 <sp:EncryptedElements
                       xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
-                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing">//wsa:To</sp:XPath>
+                     <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+                        >/soap:Envelope/soap:Header/wsa:To</sp:XPath>
                 </sp:EncryptedElements>
                 <sp:SignedParts
                     xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/req-elements-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/req-elements-policy.xml?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/req-elements-policy.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/req-elements-policy.xml
Fri Oct 18 11:35:08 2013
@@ -41,7 +41,9 @@
                 </sp:AsymmetricBinding>
                 <sp:RequiredElements
                       xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
-                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing">//wsa:To</sp:XPath>
+                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+                        >/soap:Envelope/soap:Header/wsa:To</sp:XPath>
                 </sp:RequiredElements>
                 <sp:SignedParts
                     xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/signed-elements-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/signed-elements-policy.xml?rev=1533398&r1=1533397&r2=1533398&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/signed-elements-policy.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/parts/signed-elements-policy.xml
Fri Oct 18 11:35:08 2013
@@ -41,7 +41,9 @@
                 </sp:AsymmetricBinding>
                 <sp:SignedElements
                       xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
-                    <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing">//wsa:To</sp:XPath>
+                     <sp:XPath xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+                        >/soap:Envelope/soap:Header/wsa:To</sp:XPath>
                 </sp:SignedElements>
                 <wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"
/>
             </wsp:All>



Mime
View raw message