Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5196EEA3A for ; Thu, 24 Jan 2013 12:20:28 +0000 (UTC) Received: (qmail 39867 invoked by uid 500); 24 Jan 2013 12:20:28 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 39628 invoked by uid 500); 24 Jan 2013 12:20:22 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 39601 invoked by uid 99); 24 Jan 2013 12:20:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2013 12:20:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2013 12:20:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 995982388847; Thu, 24 Jan 2013 12:20:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: jpell@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130124122000.995982388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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"> - myurl + usernamepassword - - + + + + + + + + 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 @@ - + + + + + + + + .*_EXPORT_.* + .*_EXPORT1024_.* + .*_WITH_DES_.* + .*_WITH_AES_.* + .*_WITH_NULL_.* + .*_DH_anon_.* + + + + + + + + - - + + @@ -64,16 +84,12 @@ - - - - @@ -82,7 +98,7 @@ @@ -94,6 +110,20 @@ + + + + + + + + + + +