cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject svn commit: r1437972 - in /cxf/branches/2.7.x-fixes/systests/ws-security/src/test: java/org/apache/cxf/systest/ws/policy/ resources/java_first_policies/ resources/org/apache/cxf/systest/ws/policy/client/ resources/org/apache/cxf/systest/ws/policy/server/
Date Thu, 24 Jan 2013 12:20:00 GMT
Author: jpell
Date: Thu Jan 24 12:19:59 2013
New Revision: 1437972

URL: http://svn.apache.org/viewvc?rev=1437972&view=rev
Log:
CXF-4776 cleanup of test cases

Added:
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/UsernamePasswordAttachment.xml
      - copied, changed from r1437926, cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/AttachmentPolicy.xml
Removed:
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/UsernameTokenValidator.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/AttachmentPolicy.xml
Modified:
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstAttachmentPolicyService.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/URIDomainExpressionBuilder.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/UriDomainExpression.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/javafirstclient.xml
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/server/javafirstserver.xml

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstAttachmentPolicyService.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/JavaFirstAttachmentPolicyService.java?rev=1437972&r1=1437971&r2=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstAttachmentPolicyService.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstAttachmentPolicyService.java
Thu Jan 24 12:19:59 2013
@@ -35,6 +35,5 @@ public interface JavaFirstAttachmentPoli
     void doOutputMessagePolicy();
     
     @WebMethod(operationName = "doNoPolicy")
-    void doNoPolicy();
-    
+    void doNoPolicy();    
 }

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=1437972&r1=1437971&r2=1437972&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
Thu Jan 24 12:19:59 2013
@@ -71,7 +71,8 @@ public class JavaFirstPolicyServiceTest 
     }
     
     @org.junit.Test
-    public void testExecuteJavaFirstWebService() {
+    @org.junit.Ignore
+    public void testUsernameTokenInterceptorNoPasswordValidation() {
         ClassPathXmlApplicationContext ctx = 
             new ClassPathXmlApplicationContext("org/apache/cxf/systest/ws/policy/client/javafirstclient.xml");
         
@@ -80,8 +81,7 @@ public class JavaFirstPolicyServiceTest 
         
         Client client = ClientProxy.getClient(svc);
         client.getEndpoint().getEndpointInfo().setAddress(
-                                "http://localhost:" + PORT2 + "/JavaFirstAttachmentPolicyService");
-        
+                                "http://localhost:" + PORT + "/JavaFirstAttachmentPolicyService");
        
         WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor();
         client.getEndpoint().getOutInterceptors().add(wssOut);
@@ -98,7 +98,6 @@ public class JavaFirstPolicyServiceTest 
             assertTrue(true);
         }
         
-        // this test only 'works' because I overrode the default UsernameTokenValidator
         wssOut.setProperties(getNoPasswordProperties("alice"));
         
         try {
@@ -109,6 +108,44 @@ public class JavaFirstPolicyServiceTest 
         }
     }
     
+    @org.junit.Test
+    @org.junit.Ignore
+    public void testUsernameTokenPolicyValidatorNoPasswordValidation() {
+        ClassPathXmlApplicationContext ctx = 
+            new ClassPathXmlApplicationContext("org/apache/cxf/systest/ws/policy/client/javafirstclient.xml");
+        
+        SslUsernamePasswordAttachmentService svc = 
+            (SslUsernamePasswordAttachmentService) ctx.getBean("SslUsernamePasswordAttachmentServiceClient");
+        
+        Client client = ClientProxy.getClient(svc);
+        client.getEndpoint().getEndpointInfo().setAddress(
+                                "https://localhost:" + PORT2 + "/SslUsernamePasswordAttachmentService");
+       
+        WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor();
+        client.getEndpoint().getOutInterceptors().add(wssOut);
+        
+        // just some basic sanity tests first to make sure that auth is working where password
is provided.
+        wssOut.setProperties(getPasswordProperties("alice", "password"));
+        svc.doSslAndUsernamePasswordPolicy();
+        
+        wssOut.setProperties(getPasswordProperties("alice", "passwordX"));
+        try {
+            svc.doSslAndUsernamePasswordPolicy();
+            fail("Expected authentication failure");
+        } catch (Exception e) {
+            assertTrue(true);
+        }
+        
+        wssOut.setProperties(getNoPasswordProperties("alice"));
+        
+        try {
+            svc.doSslAndUsernamePasswordPolicy();
+            fail("Expected authentication failure");
+        } catch (Exception e) {
+            assertTrue(true);
+        }
+    }
+    
     private Map<String, Object> getPasswordProperties(String username, String password)
{
         UTPasswordCallback callback = new UTPasswordCallback();
         callback.setAliasPassword(username, password);
@@ -216,7 +253,7 @@ public class JavaFirstPolicyServiceTest 
     }
 
     private Document loadWsdl(String serviceName) throws Exception {
-        HttpURLConnection connection = getHttpConnection("http://localhost:" + PORT2
+        HttpURLConnection connection = getHttpConnection("http://localhost:" + PORT
                                                          + "/" + serviceName + "?wsdl");
         InputStream is = connection.getInputStream();
         String wsdlContents = IOUtils.toString(is);

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/URIDomainExpressionBuilder.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/URIDomainExpressionBuilder.java?rev=1437972&r1=1437971&r2=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/URIDomainExpressionBuilder.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/URIDomainExpressionBuilder.java
Thu Jan 24 12:19:59 2013
@@ -35,7 +35,7 @@ public class URIDomainExpressionBuilder 
 
     @Override
     public DomainExpression build(Element paramElement) {
-        return new UriDomainExpression();
+        return new UriDomainExpression(paramElement.getTextContent());
     }
 
     @Override

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/UriDomainExpression.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/UriDomainExpression.java?rev=1437972&r1=1437971&r2=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/UriDomainExpression.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/UriDomainExpression.java
Thu Jan 24 12:19:59 2013
@@ -28,7 +28,10 @@ import org.apache.cxf.service.model.Serv
 import org.apache.cxf.ws.policy.attachment.external.DomainExpression;
 
 public class UriDomainExpression implements DomainExpression {
-    public UriDomainExpression() {
+    private final String url;
+    
+    public UriDomainExpression(final String url) {
+        this.url = url;
     }
 
     @Override
@@ -37,16 +40,30 @@ public class UriDomainExpression impleme
     }
 
     @Override
-    public boolean appliesTo(BindingMessageInfo paramBindingMessageInfo) {
-        return ("doInputMessagePolicy".equals(paramBindingMessageInfo.getBindingOperation().getName().getLocalPart())

-            && MessageInfo.Type.INPUT.equals(paramBindingMessageInfo.getMessageInfo().getType()))
-            || ("doOutputMessagePolicy".equals(paramBindingMessageInfo.getBindingOperation().getName().getLocalPart())

-            && MessageInfo.Type.OUTPUT.equals(paramBindingMessageInfo.getMessageInfo().getType()));
+    public boolean appliesTo(BindingMessageInfo bmi) {
+        String serviceName = 
+            bmi.getBindingOperation().getBinding().getService().getName().getLocalPart();
+        
+        if ("JavaFirstAttachmentPolicyService".equals(serviceName) && "usernamepassword".equals(url))
{
+            return ("doInputMessagePolicy".equals(bmi.getBindingOperation().getName().getLocalPart())

+                && MessageInfo.Type.INPUT.equals(bmi.getMessageInfo().getType()))
+                || ("doOutputMessagePolicy".equals(bmi.getBindingOperation().getName().getLocalPart())

+                && MessageInfo.Type.OUTPUT.equals(bmi.getMessageInfo().getType()));
+        } else if ("SslUsernamePasswordAttachmentService".equals(serviceName) 
+            && "sslusernamepassword".equals(url)) {
+            return MessageInfo.Type.INPUT.equals(bmi.getMessageInfo().getType());
+        } else {
+            return false;
+        }
     }
 
     @Override
-    public boolean appliesTo(BindingOperationInfo paramBindingOperationInfo) {
-        return "doOperationLevelPolicy".equals(paramBindingOperationInfo.getName().getLocalPart());
+    public boolean appliesTo(BindingOperationInfo boi) {
+        if ("usernamepassword".equals(url)) {
+            return "doOperationLevelPolicy".equals(boi.getName().getLocalPart());
+        } else {
+            return false;
+        }
     }
 
     @Override

Copied: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/UsernamePasswordAttachment.xml
(from r1437926, cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/AttachmentPolicy.xml)
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/UsernamePasswordAttachment.xml?p2=cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/UsernamePasswordAttachment.xml&p1=cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/AttachmentPolicy.xml&r1=1437926&r2=1437972&rev=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/AttachmentPolicy.xml
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/java_first_policies/UsernamePasswordAttachment.xml
Thu Jan 24 12:19:59 2013
@@ -4,7 +4,7 @@
 	xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
 
 	<wsp:AppliesTo>
-		<wsp:URI>myurl</wsp:URI>
+		<wsp:URI>usernamepassword</wsp:URI>
 	</wsp:AppliesTo>
 
 	<wsp:Policy wsu:Id="UsernameToken"

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/javafirstclient.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/javafirstclient.xml?rev=1437972&r1=1437971&r2=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/javafirstclient.xml
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/javafirstclient.xml
Thu Jan 24 12:19:59 2013
@@ -53,8 +53,15 @@
 		<jaxws:properties>
 			<entry key="ws-security.username" value="jason" />
 		</jaxws:properties>
-		
-		
 	</jaxws:client>
 	
+	<jaxws:client 
+		id="SslUsernamePasswordAttachmentServiceClient" serviceClass="org.apache.cxf.systest.ws.policy.SslUsernamePasswordAttachmentService">
+		<jaxws:properties>
+			<entry key="ws-security.username" value="jason" />
+		</jaxws:properties>
+	</jaxws:client>
+	
+	
+		
 </beans>

Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/server/javafirstserver.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/server/javafirstserver.xml?rev=1437972&r1=1437971&r2=1437972&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/server/javafirstserver.xml
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/server/javafirstserver.xml
Thu Jan 24 12:19:59 2013
@@ -35,8 +35,27 @@
 		</cxf:features>
 	</cxf:bus>
 
-	<p:externalAttachment
-		location="classpath:java_first_policies/AttachmentPolicy.xml" />
+    <httpj:engine-factory id="tls-settings">
+        <httpj:engine port="${testutil.ports.JavaFirstPolicyServer.2}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="password">
+                    <sec:keyStore type="jks" password="password" resource="org/apache/cxf/systest/ws/security/Bethal.jks"/>
+                </sec:keyManagers>
+                <sec:cipherSuitesFilter>
+                    <sec:include>.*_EXPORT_.*</sec:include>
+                    <sec:include>.*_EXPORT1024_.*</sec:include>
+                    <sec:include>.*_WITH_DES_.*</sec:include>
+                    <sec:include>.*_WITH_AES_.*</sec:include>
+                    <sec:include>.*_WITH_NULL_.*</sec:include>
+                    <sec:exclude>.*_DH_anon_.*</sec:exclude>
+                </sec:cipherSuitesFilter>
+                <sec:clientAuthentication want="true" required="false"/>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+    
+	<p:externalAttachment location="classpath:java_first_policies/UsernamePasswordAttachment.xml"
/>
+	<p:externalAttachment location="classpath:java_first_policies/SslUsernamePasswordAttachment.xml"
/>
 
 	<!-- register a policy attachment appliesto checker! -->
 	<bean id="uridomainexpressionbuilder"
@@ -45,16 +64,17 @@
 	<bean id="org.apache.cxf.systest.ws.policy.JavaFirstPolicyService"
 		class="org.apache.cxf.systest.ws.policy.JavaFirstPolicyServiceImpl" />
 
-	<bean
-		id="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService"
+	<bean id="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService"
 		class="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyServiceImpl" />
 
-	<bean
-		id="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService2"
+	<bean id="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService2"
 		class="org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyServiceImpl" />
 
+	<bean id="org.apache.cxf.systest.ws.policy.SslUsernamePasswordAttachmentService"
+		class="org.apache.cxf.systest.ws.policy.SslUsernamePasswordAttachmentServiceImpl" />
+
 	<jaxws:endpoint id="JavaFirstPolicyService"
-		address="http://localhost:${testutil.ports.JavaFirstPolicyServer.2}/JavaFirstPolicyService"
+		address="http://localhost:${testutil.ports.JavaFirstPolicyServer}/JavaFirstPolicyService"
 		implementor="#org.apache.cxf.systest.ws.policy.JavaFirstPolicyService">
 
 		<jaxws:properties>
@@ -64,16 +84,12 @@
 	</jaxws:endpoint>
 	
 	<jaxws:endpoint id="JavaFirstAttachmentPolicyService"
-		address="http://localhost:${testutil.ports.JavaFirstPolicyServer.2}/JavaFirstAttachmentPolicyService"
+		address="http://localhost:${testutil.ports.JavaFirstPolicyServer}/JavaFirstAttachmentPolicyService"
 		implementor="#org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService2">
 
 		<jaxws:properties>
 			<entry key="ws-security.callback-handler"
 				value="org.apache.cxf.systest.ws.wssec10.client.UTPasswordCallback" />
-				
-			<entry key="ws-security.ut.validator">
-				<bean class="org.apache.cxf.systest.ws.policy.UsernameTokenValidator" />
-			</entry>
 		</jaxws:properties>
 
 		<jaxws:features>
@@ -82,7 +98,7 @@
 	</jaxws:endpoint>
 
 	<jaxws:endpoint id="JavaFirstAttachmentPolicyService2"
-		address="http://localhost:${testutil.ports.JavaFirstPolicyServer.2}/JavaFirstAttachmentPolicyService2"
+		address="http://localhost:${testutil.ports.JavaFirstPolicyServer}/JavaFirstAttachmentPolicyService2"
 		implementor="#org.apache.cxf.systest.ws.policy.JavaFirstAttachmentPolicyService">
 
 		<jaxws:properties>
@@ -94,6 +110,20 @@
 			<p:policies />
 		</jaxws:features>
 	</jaxws:endpoint>
+	
+	<jaxws:endpoint id="SslUsernamePasswordAttachmentService"
+		address="https://localhost:${testutil.ports.JavaFirstPolicyServer.2}/SslUsernamePasswordAttachmentService"
+		implementor="#org.apache.cxf.systest.ws.policy.SslUsernamePasswordAttachmentService">
+
+		<jaxws:properties>
+			<entry key="ws-security.callback-handler"
+				value="org.apache.cxf.systest.ws.wssec10.client.UTPasswordCallback" />
+		</jaxws:properties>
+
+		<jaxws:features>
+			<p:policies />
+		</jaxws:features>
+	</jaxws:endpoint>
 
 	<wsp:Policy wsu:Id="InternalTransportAndUsernamePolicy"
 		xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"



Mime
View raw message