cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1485145 - in /cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut: StaxUsernameTokenTest.java UsernameTokenTest.java
Date Wed, 22 May 2013 10:44:45 GMT
Author: coheigea
Date: Wed May 22 10:44:45 2013
New Revision: 1485145

URL: http://svn.apache.org/r1485145
Log:
Added interop tests for UsernameTokens over TLS

Modified:
    cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java
    cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java

Modified: cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java?rev=1485145&r1=1485144&r2=1485145&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java
(original)
+++ cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java
Wed May 22 10:44:45 2013
@@ -38,6 +38,7 @@ import org.junit.BeforeClass;
 
 /**
  * A set of tests for Username Tokens over the Transport Binding using the streaming interceptors.
+ * It tests both DOM + StAX clients against the StAX server
  */
 public class StaxUsernameTokenTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(StaxServer.class);
@@ -78,6 +79,16 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -101,6 +112,16 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -124,6 +145,16 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -147,6 +178,16 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -169,6 +210,17 @@ public class StaxUsernameTokenTest exten
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -191,6 +243,17 @@ public class StaxUsernameTokenTest exten
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -213,6 +276,17 @@ public class StaxUsernameTokenTest exten
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -236,6 +310,23 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        try {
+            utPort.doubleIt(25);
+            fail("Failure expected on no UsernameToken");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "UsernameToken not satisfied";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        /*
+        // TODO
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         try {
             utPort.doubleIt(25);
             fail("Failure expected on no UsernameToken");
@@ -243,11 +334,12 @@ public class StaxUsernameTokenTest exten
             String error = "UsernameToken not satisfied";
             assertTrue(ex.getMessage().contains(error));
         }
+        */
         
         ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
     }
-    
+
     @org.junit.Test
     public void testPasswordHashedReplay() throws Exception {
 
@@ -302,8 +394,29 @@ public class StaxUsernameTokenTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
         ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
+        utPort.doubleIt(25);
+        
+        try {
+            ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME,
"Frank");
+            utPort.doubleIt(30);
+            fail("Failure expected on a user with the wrong role");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "Unauthorized";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        /*
+        // TODO
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         
+        ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
         utPort.doubleIt(25);
         
         try {
@@ -314,8 +427,10 @@ public class StaxUsernameTokenTest exten
             String error = "Unauthorized";
             assertTrue(ex.getMessage().contains(error));
         }
+        */
         
         ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
     }
+    
 }

Modified: cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java?rev=1485145&r1=1485144&r2=1485145&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
(original)
+++ cxf/branches/wss4j2.0-port/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
Wed May 22 10:44:45 2013
@@ -37,7 +37,8 @@ import org.example.contract.doubleit.Dou
 import org.junit.BeforeClass;
 
 /**
- * A set of tests for Username Tokens over the Transport Binding.
+ * A set of tests for Username Tokens over the Transport Binding. It tests both DOM + StAX
clients against the 
+ * DOM server
  */
 public class UsernameTokenTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(Server.class);
@@ -78,6 +79,16 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -101,6 +112,16 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -124,6 +145,16 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -147,6 +178,16 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -169,6 +210,17 @@ public class UsernameTokenTest extends A
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -191,6 +243,17 @@ public class UsernameTokenTest extends A
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -213,6 +276,17 @@ public class UsernameTokenTest extends A
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
+        
+        // DOM
+        utPort.doubleIt(25);
+        
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -236,6 +310,24 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
+        try {
+            utPort.doubleIt(25);
+            fail("Failure expected on no UsernameToken");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "The received token does not match the token inclusion requirement";
+            assertTrue(ex.getMessage().contains(error));
+        }
+
+        /*
+        // TODO
+        // Streaming
+        ((BindingProvider)utPort).getRequestContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
+        ((BindingProvider)utPort).getResponseContext().put(
+            SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+        );
         try {
             utPort.doubleIt(25);
             fail("Failure expected on no UsernameToken");
@@ -243,6 +335,7 @@ public class UsernameTokenTest extends A
             String error = "The received token does not match the token inclusion requirement";
             assertTrue(ex.getMessage().contains(error));
         }
+        */
         
         ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
@@ -341,8 +434,23 @@ public class UsernameTokenTest extends A
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT);
         
+        // DOM
         ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
+        utPort.doubleIt(25);
         
+        try {
+            ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME,
"Frank");
+            utPort.doubleIt(30);
+            fail("Failure expected on a user with the wrong role");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            String error = "Unauthorized";
+            assertTrue(ex.getMessage().contains(error));
+        }
+        
+        // Streaming
+        /*
+        // TODO
+        ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
         utPort.doubleIt(25);
         
         try {
@@ -353,6 +461,7 @@ public class UsernameTokenTest extends A
             String error = "Unauthorized";
             assertTrue(ex.getMessage().contains(error));
         }
+        */
         
         ((java.io.Closeable)utPort).close();
         bus.shutdown(true);



Mime
View raw message