You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2013/10/14 18:06:03 UTC

svn commit: r1531957 - in /cxf/trunk: rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/ services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/ services/sts/systests/basic/src/test/java/org/apach...

Author: coheigea
Date: Mon Oct 14 16:06:03 2013
New Revision: 1531957

URL: http://svn.apache.org/r1531957
Log:
Enabled more tests

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java
    cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java
    cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java?rev=1531957&r1=1531956&r2=1531957&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java Mon Oct 14 16:06:03 2013
@@ -346,7 +346,7 @@ public abstract class AbstractStaxBindin
                 && (WSSConstants.NS_SAML.equals(el.getNamespaceURI())
                 || WSSConstants.NS_SAML2.equals(el.getNamespaceURI()))) {
                 String samlAction = ConfigurationConstants.SAML_TOKEN_UNSIGNED;
-                if (signed || endorsing) {
+                if (endorsing) {
                     samlAction = ConfigurationConstants.SAML_TOKEN_SIGNED;
                 }
                 Map<String, Object> config = getProperties();

Modified: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java?rev=1531957&r1=1531956&r2=1531957&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java (original)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java Mon Oct 14 16:06:03 2013
@@ -45,7 +45,9 @@ import org.junit.BeforeClass;
  * In this test case, a CXF client requests a Security Token from an STS, passing a username that
  * it has obtained from an unknown client as an "ActAs" element. This username is obtained
  * by parsing the "ws-security.username" property. The client then invokes on the service 
- * provider using the returned token from the STS. 
+ * provider using the returned token from the STS.
+ * 
+ * It tests both DOM + StAX clients against the DOM server.
  */
 public class UsernameActAsTest extends AbstractBusClientServerTestBase {
     
@@ -135,6 +137,58 @@ public class UsernameActAsTest extends A
         bus.shutdown(true);
     }
     
+    @org.junit.Test
+    public void testUsernameActAsStreaming() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = UsernameActAsTest.class.getResource("cxf-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = UsernameActAsTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML2BearerPort");
+        DoubleItPortType port = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        if (standalone) {
+            TokenTestUtils.updateSTSPort((BindingProvider)port, STSPORT2);
+        }
+        SecurityTestUtil.enableStreaming(port);
+        
+        // Transport port
+        ((BindingProvider)port).getRequestContext().put(
+            "ws-security.username", "alice"
+        );
+        doubleIt(port, 25);
+        
+        ((java.io.Closeable)port).close();
+        
+        DoubleItPortType port2 = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port2, PORT);
+        if (standalone) {
+            TokenTestUtils.updateSTSPort((BindingProvider)port2, STSPORT2);
+        }
+        SecurityTestUtil.enableStreaming(port2);
+        
+        ((BindingProvider)port2).getRequestContext().put(
+            "ws-security.username", "eve"
+        );
+        // This time we expect a failure as the server validator doesn't accept "eve".
+        try {
+            doubleIt(port2, 30);
+            fail("Failure expected on an unknown user");
+        } catch (Exception ex) {
+            // expected
+        }
+        
+        ((java.io.Closeable)port2).close();
+        bus.shutdown(true);
+    }
+    
     /**
      * Test caching the issued token
      */

Modified: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java?rev=1531957&r1=1531956&r2=1531957&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java (original)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java Mon Oct 14 16:06:03 2013
@@ -45,6 +45,8 @@ import org.junit.BeforeClass;
  * it has obtained from an unknown client as an "OnBehalfOf" element. This username is obtained
  * by parsing the "ws-security.username" property. The client then invokes on the service 
  * provider using the returned token from the STS. 
+ * 
+ * It tests both DOM + StAX clients against the DOM server.
  */
 public class UsernameOnBehalfOfTest extends AbstractBusClientServerTestBase {
     
@@ -137,6 +139,62 @@ public class UsernameOnBehalfOfTest exte
         bus.shutdown(true);
     }
     
+    @org.junit.Test
+    public void testUsernameOnBehalfOfStreaming() throws Exception {
+        // Only run these tests for the standalone scenario.
+        if (!standalone) {
+            return;
+        }
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = UsernameOnBehalfOfTest.class.getResource("cxf-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = UsernameOnBehalfOfTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItOBOAsymmetricSAML2BearerPort");
+        DoubleItPortType port = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+        if (standalone) {
+            TokenTestUtils.updateSTSPort((BindingProvider)port, STSPORT2);
+        }
+        SecurityTestUtil.enableStreaming(port);
+
+        // Transport port
+        ((BindingProvider)port).getRequestContext().put(
+            "ws-security.username", "alice"
+        );
+        doubleIt(port, 25);
+        
+        ((java.io.Closeable)port).close();
+        
+        DoubleItPortType port2 = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port2, PORT);
+        if (standalone) {
+            TokenTestUtils.updateSTSPort((BindingProvider)port2, STSPORT2);
+        }
+        SecurityTestUtil.enableStreaming(port2);
+        
+        ((BindingProvider)port2).getRequestContext().put(
+            "ws-security.username", "eve"
+        );
+        // This time we expect a failure as the server validator doesn't accept "eve".
+        try {
+            doubleIt(port2, 30);
+            fail("Failure expected on an unknown user");
+        } catch (Exception ex) {
+            // expected
+        }
+        
+        ((java.io.Closeable)port2).close();
+        bus.shutdown(true);
+    }
+    
     /**
      * Test caching the issued token
      */