cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject svn commit: r1445031 - in /cxf/branches/2.7.x-fixes: rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/ systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/
Date Tue, 12 Feb 2013 03:51:45 GMT
Author: jpell
Date: Tue Feb 12 03:51:45 2013
New Revision: 1445031

URL: http://svn.apache.org/r1445031
Log:
CXF-4813 re-enabled disabled test and fixed an invalid test assertion, based on Dan's fix
to wsp policy alternatives support at operation level

Modified:
    cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/OperationSimpleServiceImpl.java

Modified: cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java?rev=1445031&r1=1445030&r2=1445031&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
Tue Feb 12 03:51:45 2013
@@ -110,8 +110,14 @@ public class EffectivePolicyImpl impleme
                     PolicyEngineImpl engine, 
                     boolean requestor, boolean request) {
         Assertor assertor = initialisePolicy(ei, boi, engine, requestor, request, null);
-        chooseAlternative(engine, assertor);
-        initialiseInterceptors(engine, requestor);  
+        if (requestor || !request) {
+            chooseAlternative(engine, assertor);
+            initialiseInterceptors(engine, requestor);
+        } else {
+            //incoming server should not choose an alternative, need to include all the policies
+            Collection<Assertion> alternative = engine.getAssertions(this.policy, true);
+            this.setChosenAlternative(alternative);
+        }
     }
     
     public void initialise(EndpointInfo ei, 

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java?rev=1445031&r1=1445030&r2=1445031&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
Tue Feb 12 03:51:45 2013
@@ -50,7 +50,6 @@ import org.apache.ws.security.WSConstant
 import org.apache.ws.security.handler.WSHandlerConstants;
 
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -206,7 +205,7 @@ public class JavaFirstPolicyServiceTest 
     }
 
     @Test
-    public void testNoAltOperationNoClientCertAlternativePolicy() {
+    public void testNoAltOperationNoClientCertPolicy() {
         System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
 
         ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new
String[] {
@@ -255,7 +254,7 @@ public class JavaFirstPolicyServiceTest 
     }
 
     @Test
-    public void testNoAltOperationClientCertAlternativePolicy() {
+    public void testNoAltOperationClientCertPolicy() {
         System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
 
         ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new
String[] {
@@ -299,7 +298,6 @@ public class JavaFirstPolicyServiceTest 
     }
 
     @Test
-    @Ignore
     public void testOperationNoClientCertAlternativePolicy() {
         System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
 
@@ -310,6 +308,9 @@ public class JavaFirstPolicyServiceTest 
         OperationSimpleService simpleService = clientContext
             .getBean("OperationSimpleServiceClient", OperationSimpleService.class);
 
+        // no security on ping!
+        simpleService.ping();
+        
         try {
             simpleService.doStuff();
             fail("Expected exception as no credentials");
@@ -327,12 +328,12 @@ public class JavaFirstPolicyServiceTest 
             assertTrue(true);
         }
 
+        // this is successful because the alternative policy allows a password to be specified.
         wssOut.setProperties(getPasswordProperties("alice", "password"));
         simpleService.doStuff();
     }
 
     @Test
-    @Ignore
     public void testOperationClientCertAlternativePolicy() {
         System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
 
@@ -343,6 +344,9 @@ public class JavaFirstPolicyServiceTest 
         OperationSimpleService simpleService = clientContext
             .getBean("OperationSimpleServiceClient", OperationSimpleService.class);
 
+        // no security on ping!
+        simpleService.ping();
+        
         try {
             simpleService.doStuff();
             fail("Expected exception as no credentials");
@@ -355,20 +359,16 @@ public class JavaFirstPolicyServiceTest 
         wssOut.setProperties(getNoPasswordProperties("alice"));
         simpleService.doStuff();
 
+        // this is successful because the alternative policy allows a password to be specified.
         wssOut.setProperties(getPasswordProperties("alice", "password"));
-
-        try {
-            simpleService.doStuff();
-            fail("Expected exception password is not supported");
-        } catch (SOAPFaultException e) {
-            assertTrue(true);
-        }
+        simpleService.doStuff();
     }
 
     private WSS4JOutInterceptor addToClient(Object svc) {
         Client client = ClientProxy.getClient(svc);
         WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor();
         client.getEndpoint().getOutInterceptors().add(wssOut);
+        client.getOutInterceptors().add(wssOut);
         return wssOut;
     }
 

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/OperationSimpleServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/OperationSimpleServiceImpl.java?rev=1445031&r1=1445030&r2=1445031&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/OperationSimpleServiceImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/OperationSimpleServiceImpl.java
Tue Feb 12 03:51:45 2013
@@ -28,7 +28,8 @@ import org.apache.cxf.annotations.Policy
 endpointInterface = "org.apache.cxf.systest.ws.policy.javafirst.OperationSimpleService",

 serviceName = "OperationSimpleService", targetNamespace = "http://www.example.org/contract/OperationSimpleService")
 public class OperationSimpleServiceImpl implements OperationSimpleService {
-    @Policy(uri = "classpath:/java_first_policies/AlternativesPolicy.xml", placement = Placement.BINDING_OPERATION)
+    @Policy(uri = "classpath:/java_first_policies/AlternativesPolicy.xml", 
+        placement = Placement.BINDING_OPERATION_INPUT)
     @Override
     public void doStuff() {
     }



Mime
View raw message