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 2019/03/22 16:43:53 UTC
[cxf] branch 3.2.x-fixes updated: CXF-7979 - Adding a test-case
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
new b6ebe5c CXF-7979 - Adding a test-case
b6ebe5c is described below
commit b6ebe5c08ce57a62921103570e90bbbe0038b2f2
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Mar 22 16:23:12 2019 +0000
CXF-7979 - Adding a test-case
(cherry picked from commit 6bf89e9c8804c8845ec4d38583dd33eea8256439)
---
.../apache/cxf/systest/ws/x509/X509TokenTest.java | 59 ++++++++++++++++++++++
.../apache/cxf/systest/ws/x509/DoubleItX509.wsdl | 22 ++++++++
.../org/apache/cxf/systest/ws/x509/client.xml | 9 ++++
.../org/apache/cxf/systest/ws/x509/server.xml | 8 +++
.../org/apache/cxf/systest/ws/x509/stax-server.xml | 9 ++++
5 files changed, 107 insertions(+)
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
index 28d14af..97271f7 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
@@ -19,15 +19,27 @@
package org.apache.cxf.systest.ws.x509;
+import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
@@ -35,7 +47,9 @@ import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.systest.ws.common.SecurityTestUtil;
import org.apache.cxf.systest.ws.common.TestParam;
import org.apache.cxf.systest.ws.ut.SecurityHeaderCacheInterceptor;
@@ -526,6 +540,50 @@ public class X509TokenTest extends AbstractBusClientServerTestBase {
}
@org.junit.Test
+ public void testAsymmetricIssuerSerialDispatch() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = X509TokenTest.class.getResource("client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ BusFactory.setDefaultBus(bus);
+ BusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricIssuerSerialOperationPort");
+
+ Dispatch<Source> disp = service.createDispatch(portQName, Source.class, Mode.PAYLOAD);
+ updateAddressPort(disp, test.getPort());
+
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(disp);
+ }
+
+ // We need to set the wsdl operation name here, or otherwise the policy layer won't pick
+ // up the security policy attached at the operation level
+ QName wsdlOperationQName = new QName(NAMESPACE, "DoubleIt");
+ disp.getRequestContext().put(MessageContext.WSDL_OPERATION, wsdlOperationQName);
+
+ String req = "<ns2:DoubleIt xmlns:ns2=\"http://www.example.org/schema/DoubleIt\">"
+ + "<numberToDouble>25</numberToDouble></ns2:DoubleIt>";
+ Source source = new StreamSource(new StringReader(req));
+ source = disp.invoke(source);
+
+ Node nd = StaxUtils.read(source);
+ if (nd instanceof Document) {
+ nd = ((Document)nd).getDocumentElement();
+ }
+ Map<String, String> ns = new HashMap<>();
+ ns.put("ns2", "http://www.example.org/schema/DoubleIt");
+ XPathUtils xp = new XPathUtils(ns);
+ Object o = xp.getValue("//ns2:DoubleItResponse/doubledNumber", nd, XPathConstants.STRING);
+ assertEquals(StaxUtils.toString(nd), "50", o);
+
+ bus.shutdown(true);
+ }
+
+ @org.junit.Test
public void testAsymmetricSHA512() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
@@ -1627,4 +1685,5 @@ public class X509TokenTest extends AbstractBusClientServerTestBase {
((java.io.Closeable)port).close();
bus.shutdown(true);
}
+
}
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl
index 868aa44..d3f1f00 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl
@@ -264,6 +264,25 @@
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
+ <wsdl:binding name="DoubleItAsymmetricIssuerSerialOperationBinding" type="tns:DoubleItPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="DoubleIt">
+ <soap:operation soapAction=""/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ <wsp:PolicyReference URI="#DoubleItAsymmetricIssuerSerialPolicy"/>
+ <wsp:PolicyReference URI="#DoubleItBinding_DoubleIt_Input_Policy"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ <wsp:PolicyReference URI="#DoubleItAsymmetricIssuerSerialPolicy"/>
+ <wsp:PolicyReference URI="#DoubleItBinding_DoubleIt_Output_Policy"/>
+ </wsdl:output>
+ <wsdl:fault name="DoubleItFault">
+ <soap:body use="literal" name="DoubleItFault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
<wsdl:binding name="DoubleItAsymmetricSHA512Binding" type="tns:DoubleItPortType">
<wsp:PolicyReference URI="#DoubleItAsymmetricSHA512Policy"/>
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -715,6 +734,9 @@
<wsdl:port name="DoubleItAsymmetricIssuerSerialPort" binding="tns:DoubleItAsymmetricIssuerSerialBinding">
<soap:address location="http://localhost:9001/DoubleItX509Asymmetric"/>
</wsdl:port>
+ <wsdl:port name="DoubleItAsymmetricIssuerSerialOperationPort" binding="tns:DoubleItAsymmetricIssuerSerialOperationBinding">
+ <soap:address location="http://localhost:9001/DoubleItX509AsymmetricOperation"/>
+ </wsdl:port>
<wsdl:port name="DoubleItAsymmetricSHA512Port" binding="tns:DoubleItAsymmetricSHA512Binding">
<soap:address location="http://localhost:9001/DoubleItX509AsymmetricSHA512"/>
</wsdl:port>
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml
index 2bf31bd..0aa3739 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml
@@ -130,6 +130,15 @@
<entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
</jaxws:properties>
</jaxws:client>
+ <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItAsymmetricIssuerSerialOperationPort" 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>
<jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItAsymmetricSHA512Port" createdFromAPI="true">
<jaxws:properties>
<entry key="security.encryption.properties" value="bob.properties"/>
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml
index bc0bdfa..2191e44 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml
@@ -143,6 +143,14 @@
<entry key="security.encryption.username" value="alice"/>
</jaxws:properties>
</jaxws:endpoint>
+ <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricOperation" address="http://localhost:${testutil.ports.x509.Server}/DoubleItX509AsymmetricOperation" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricIssuerSerialOperationPort" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.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>
<jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricSHA512" address="http://localhost:${testutil.ports.x509.Server}/DoubleItX509AsymmetricSHA512" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricSHA512Port" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl">
<jaxws:properties>
<entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml
index 250ce1d..b37349f 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml
@@ -158,6 +158,15 @@
<entry key="ws-security.enable.streaming" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
+ <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricOperation" address="http://localhost:${testutil.ports.x509.StaxServer}/DoubleItX509AsymmetricOperation" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricIssuerSerialOperationPort" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.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>
<jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricSHA512" address="http://localhost:${testutil.ports.x509.StaxServer}/DoubleItX509AsymmetricSHA512" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricSHA512Port" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl">
<jaxws:properties>
<entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>