Adding tests for derived Symmetric attachments
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/29a95b39 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/29a95b39 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/29a95b39 Branch: refs/heads/3.0.x-fixes Commit: 29a95b39713324dfdfd6349b421d3fa19346a1bd Parents: 13fe678 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Thu Jun 18 14:11:48 2015 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Thu Jun 18 15:24:04 2015 +0100 ---------------------------------------------------------------------- .../cxf/systest/ws/swa/SWAPolicyTest.java | 59 ++++++++ .../apache/cxf/systest/ws/swa/DoubleItSwa.wsdl | 134 ++++++++++++++++++- .../apache/cxf/systest/ws/swa/policy-client.xml | 17 +++ .../apache/cxf/systest/ws/swa/policy-server.xml | 24 ++++ .../cxf/systest/ws/swa/stax-policy-server.xml | 26 ++++ 5 files changed, 259 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/29a95b39/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java index 64a3fd1..a76f002 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java @@ -205,6 +205,35 @@ public class SWAPolicyTest extends AbstractBusClientServerTestBase { } @org.junit.Test + public void testSWACombinedDerivedPolicy() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = SWAPolicyTest.class.getResource("policy-client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = SWAPolicyTest.class.getResource("DoubleItSwa.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItSWACombinedDerivedPolicyPort"); + DoubleItSwaPortType port = + service.getPort(portQName, DoubleItSwaPortType.class); + updateAddressPort(port, test.getPort()); + + if (test.isStreaming()) { + enableStreaming(port); + } + + DoubleIt3 doubleIt = new DoubleIt3(); + doubleIt.setNumberToDouble(25); + port.doubleIt3(doubleIt, "12345".getBytes()); + + ((java.io.Closeable)port).close(); + bus.shutdown(true); + } + + @org.junit.Test public void testSWACombinedAsymmetricPolicy() throws Exception { SpringBusFactory bf = new SpringBusFactory(); @@ -233,6 +262,36 @@ public class SWAPolicyTest extends AbstractBusClientServerTestBase { bus.shutdown(true); } + @org.junit.Test + @org.junit.Ignore + public void testSWACombinedAsymmetricDerivedPolicy() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = SWAPolicyTest.class.getResource("policy-client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = SWAPolicyTest.class.getResource("DoubleItSwa.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItSWACombinedAsymmetricDerivedPolicyPort"); + DoubleItSwaPortType port = + service.getPort(portQName, DoubleItSwaPortType.class); + updateAddressPort(port, test.getPort()); + + if (test.isStreaming()) { + enableStreaming(port); + } + + DoubleIt3 doubleIt = new DoubleIt3(); + doubleIt.setNumberToDouble(25); + port.doubleIt3(doubleIt, "12345".getBytes()); + + ((java.io.Closeable)port).close(); + bus.shutdown(true); + } + static void enableStreaming(DoubleItSwaPortType port) { ((BindingProvider)port).getRequestContext().put( SecurityConstants.ENABLE_STREAMING_SECURITY, "true" http://git-wip-us.apache.org/repos/asf/cxf/blob/29a95b39/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl index 78d58e4..b37b162 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl @@ -141,7 +141,32 @@ </wsdl:fault> </wsdl:operation> </wsdl:binding> - <wsdl:binding name="DoubleItCombinedAsymmetricBinding" type="tns:DoubleItSwaPortType"> + <wsdl:binding name="DoubleItCombinedDerivedBinding" type="tns:DoubleItSwaPortType"> + <wsp:PolicyReference URI="#DoubleItSymmetricDerivedPolicy"/> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="DoubleIt3"> + <soap:operation soapAction=""/> + <wsdl:input> + <mime:multipartRelated> + <mime:part> + <soap:body use="literal"/> + </mime:part> + <mime:part> + <mime:content part="attachment" type="image/jpeg"/> + </mime:part> + </mime:multipartRelated> + <wsp:PolicyReference URI="#Combined_Policy"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + <wsp:PolicyReference URI="#Combined_Policy"/> + </wsdl:output> + <wsdl:fault name="DoubleItFault"> + <soap:body use="literal" name="DoubleItFault"/> + </wsdl:fault> + </wsdl:operation> + </wsdl:binding> + <wsdl:binding name="DoubleItCombinedAsymmetricBinding" type="tns:DoubleItSwaPortType"> <wsp:PolicyReference URI="#DoubleItAsymmetricPolicy"/> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="DoubleIt3"> @@ -166,6 +191,31 @@ </wsdl:fault> </wsdl:operation> </wsdl:binding> + <wsdl:binding name="DoubleItCombinedAsymmetricDerivedBinding" type="tns:DoubleItSwaPortType"> + <wsp:PolicyReference URI="#DoubleItAsymmetricDerivedPolicy"/> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="DoubleIt3"> + <soap:operation soapAction=""/> + <wsdl:input> + <mime:multipartRelated> + <mime:part> + <soap:body use="literal"/> + </mime:part> + <mime:part> + <mime:content part="attachment" type="image/jpeg"/> + </mime:part> + </mime:multipartRelated> + <wsp:PolicyReference URI="#Combined_Policy"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + <wsp:PolicyReference URI="#Combined_Policy"/> + </wsdl:output> + <wsdl:fault name="DoubleItFault"> + <soap:body use="literal" name="DoubleItFault"/> + </wsdl:fault> + </wsdl:operation> + </wsdl:binding> <wsdl:service name="DoubleItService"> <wsdl:port name="DoubleItSWASignatureContentActionPort" binding="tns:DoubleItNoSecurityBinding"> @@ -192,9 +242,15 @@ <wsdl:port name="DoubleItSWACombinedPolicyPort" binding="tns:DoubleItCombinedBinding"> <soap:address location="http://localhost:9001/DoubleItSWACombinedPolicy"/> </wsdl:port> + <wsdl:port name="DoubleItSWACombinedDerivedPolicyPort" binding="tns:DoubleItCombinedDerivedBinding"> + <soap:address location="http://localhost:9001/DoubleItSWACombinedDerivedPolicy"/> + </wsdl:port> <wsdl:port name="DoubleItSWACombinedAsymmetricPolicyPort" binding="tns:DoubleItCombinedAsymmetricBinding"> <soap:address location="http://localhost:9001/DoubleItSWACombinedAsymmetricPolicy"/> </wsdl:port> + <wsdl:port name="DoubleItSWACombinedAsymmetricDerivedPolicyPort" binding="tns:DoubleItCombinedAsymmetricDerivedBinding"> + <soap:address location="http://localhost:9001/DoubleItSWACombinedAsymmetricDerivedPolicy"/> + </wsdl:port> </wsdl:service> <wsp:Policy wsu:Id="DoubleItSymmetricPolicy"> @@ -229,6 +285,39 @@ </wsp:ExactlyOne> </wsp:Policy> + <wsp:Policy wsu:Id="DoubleItSymmetricDerivedPolicy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:SymmetricBinding> + <wsp:Policy> + <sp:ProtectionToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10/> + <sp:RequireDerivedKeys/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:ProtectionToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128/> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:SymmetricBinding> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + <wsp:Policy wsu:Id="DoubleItAsymmetricPolicy"> <wsp:ExactlyOne> <wsp:All> @@ -270,6 +359,49 @@ </wsp:ExactlyOne> </wsp:Policy> + <wsp:Policy wsu:Id="DoubleItAsymmetricDerivedPolicy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:AsymmetricBinding> + <wsp:Policy> + <sp:InitiatorToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10/> + <sp:RequireDerivedKeys/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:InitiatorToken> + <sp:RecipientToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10/> + <sp:RequireDerivedKeys/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:RecipientToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128/> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:AsymmetricBinding> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + <wsp:Policy wsu:Id="Signature_Content_Policy"> <wsp:ExactlyOne> <wsp:All> http://git-wip-us.apache.org/repos/asf/cxf/blob/29a95b39/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-client.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-client.xml index 24438ab..7bfb753 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-client.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-client.xml @@ -53,6 +53,13 @@ </jaxws:properties> </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSWACombinedDerivedPolicyPort" createdFromAPI="true"> + <jaxws:properties> + <entry key="security.encryption.properties" value="bob.properties"/> + <entry key="security.encryption.username" value="bob"/> + </jaxws:properties> + </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSWACombinedAsymmetricPolicyPort" createdFromAPI="true"> <jaxws:properties> <entry key="ws-security.encryption.properties" value="bob.properties"/> @@ -63,4 +70,14 @@ </jaxws:properties> </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSWACombinedAsymmetricDerivedPolicyPort" createdFromAPI="true"> + <jaxws:properties> + <entry key="security.encryption.properties" value="bob.properties"/> + <entry key="security.encryption.username" value="bob"/> + <entry key="security.signature.properties" value="alice.properties"/> + <entry key="security.signature.username" value="alice"/> + <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + </jaxws:properties> + </jaxws:client> + </beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/29a95b39/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-server.xml index ff80cc8..708eb02 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/policy-server.xml @@ -70,6 +70,17 @@ </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedDerivedPolicy" + address="http://localhost:${testutil.ports.swa.PolicyServer}/DoubleItSWACombinedDerivedPolicy" + serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedDerivedPolicyPort" + implementor="org.apache.cxf.systest.ws.swa.DoubleIt3Impl" + wsdlLocation="org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl"> + <jaxws:properties> + <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + <entry key="security.signature.properties" value="bob.properties"/> + </jaxws:properties> + </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedAsymmetricPolicy" address="http://localhost:${testutil.ports.swa.PolicyServer}/DoubleItSWACombinedAsymmetricPolicy" serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedAsymmetricPolicyPort" @@ -83,4 +94,17 @@ </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedAsymmetricDerivedPolicy" + address="http://localhost:${testutil.ports.swa.PolicyServer}/DoubleItSWACombinedAsymmetricDerivedPolicy" + serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedAsymmetricDerivedPolicyPort" + implementor="org.apache.cxf.systest.ws.swa.DoubleIt3Impl" + wsdlLocation="org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl"> + <jaxws:properties> + <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + <entry key="security.signature.properties" value="bob.properties"/> + <entry key="security.encryption.properties" value="alice.properties"/> + <entry key="security.encryption.username" value="alice"/> + </jaxws:properties> + </jaxws:endpoint> + </beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/29a95b39/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/stax-policy-server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/stax-policy-server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/stax-policy-server.xml index b8d6a67..d8523a2 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/stax-policy-server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/swa/stax-policy-server.xml @@ -74,6 +74,18 @@ </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedDerivedPolicy" + address="http://localhost:${testutil.ports.swa.StaxPolicyServer}/DoubleItSWACombinedDerivedPolicy" + serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedDerivedPolicyPort" + implementor="org.apache.cxf.systest.ws.swa.DoubleIt3Impl" + wsdlLocation="org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl"> + <jaxws:properties> + <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + <entry key="security.signature.properties" value="bob.properties"/> + <entry key="ws-security.enable.streaming" value="true"/> + </jaxws:properties> + </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedAsymmetricPolicy" address="http://localhost:${testutil.ports.swa.StaxPolicyServer}/DoubleItSWACombinedAsymmetricPolicy" serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedAsymmetricPolicyPort" @@ -88,4 +100,18 @@ </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="CombinedAsymmetricDerivedPolicy" + address="http://localhost:${testutil.ports.swa.StaxPolicyServer}/DoubleItSWACombinedAsymmetricDerivedPolicy" + serviceName="s:DoubleItService" endpointName="s:DoubleItSWACombinedAsymmetricDerivedPolicyPort" + implementor="org.apache.cxf.systest.ws.swa.DoubleIt3Impl" + wsdlLocation="org/apache/cxf/systest/ws/swa/DoubleItSwa.wsdl"> + <jaxws:properties> + <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + <entry key="security.signature.properties" value="bob.properties"/> + <entry key="security.encryption.properties" value="alice.properties"/> + <entry key="security.encryption.username" value="alice"/> + <entry key="ws-security.enable.streaming" value="true"/> + </jaxws:properties> + </jaxws:endpoint> + </beans>