cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [cxf] branch master updated: Adding a one-way WS-Security + WS-Addressing test
Date Fri, 08 Jun 2018 14:27:59 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new c78b022  Adding a one-way WS-Security + WS-Addressing test
c78b022 is described below

commit c78b022fc859105f62a4fac3c8ba788177d7e0dc
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Fri Jun 8 15:27:19 2018 +0100

    Adding a one-way WS-Security + WS-Addressing test
---
 .../cxf/systest/ws/common/DoubleItOneWayImpl.java  | 37 ++++++++++++++++++++++
 .../cxf/systest/ws/common/SecurityTestUtil.java    |  8 +++--
 .../apache/cxf/systest/ws/x509/X509TokenTest.java  | 28 ++++++++++++++++
 .../src/test/resources/DoubleItLogical.wsdl        |  5 +++
 .../apache/cxf/systest/ws/x509/DoubleItX509.wsdl   | 16 +++++++++-
 .../org/apache/cxf/systest/ws/x509/client.xml      |  6 ++++
 .../org/apache/cxf/systest/ws/x509/server.xml      |  6 ++++
 .../org/apache/cxf/systest/ws/x509/stax-server.xml |  7 ++++
 8 files changed, 110 insertions(+), 3 deletions(-)

diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/DoubleItOneWayImpl.java
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/DoubleItOneWayImpl.java
new file mode 100644
index 0000000..2acf024
--- /dev/null
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/DoubleItOneWayImpl.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.common;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.feature.Features;
+import org.example.contract.doubleit.DoubleItOneWayPortType;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt",
+            serviceName = "DoubleItService",
+            endpointInterface = "org.example.contract.doubleit.DoubleItOneWayPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class DoubleItOneWayImpl implements DoubleItOneWayPortType {
+
+    @Override
+    public void doubleIt(int numberToDouble) {
+        numberToDouble *= 2;
+    }
+
+}
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
index 278f36e..d231896 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
@@ -80,10 +80,14 @@ public final class SecurityTestUtil {
     }
 
     public static void enableStreaming(DoubleItPortType port) {
-        ((BindingProvider)port).getRequestContext().put(
+        enableStreaming((BindingProvider)port);
+    }
+
+    public static void enableStreaming(BindingProvider bindingProvider) {
+        bindingProvider.getRequestContext().put(
             SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
         );
-        ((BindingProvider)port).getResponseContext().put(
+        bindingProvider.getResponseContext().put(
             SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
         );
     }
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 f9d1466..25fdfe5 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
@@ -42,6 +42,7 @@ import org.apache.cxf.systest.ws.ut.SecurityHeaderCacheInterceptor;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.wss4j.common.ext.WSSecurityException;
+import org.example.contract.doubleit.DoubleItOneWayPortType;
 import org.example.contract.doubleit.DoubleItPortType;
 import org.example.contract.doubleit.DoubleItPortType2;
 
@@ -1599,4 +1600,31 @@ public class X509TokenTest extends AbstractBusClientServerTestBase
{
         ((java.io.Closeable)x509Port).close();
         bus.shutdown(true);
     }
+
+    @org.junit.Test
+    public void testSymmetricAddressingOneWay() 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, "DoubleItSymmetricAddressingOneWayPort");
+        DoubleItOneWayPortType port =
+                service.getPort(portQName, DoubleItOneWayPortType.class);
+        updateAddressPort(port, test.getPort());
+
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming((BindingProvider)port);
+        }
+
+        port.doubleIt(30);
+
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
 }
diff --git a/systests/ws-security/src/test/resources/DoubleItLogical.wsdl b/systests/ws-security/src/test/resources/DoubleItLogical.wsdl
index 768ac76..832852a 100644
--- a/systests/ws-security/src/test/resources/DoubleItLogical.wsdl
+++ b/systests/ws-security/src/test/resources/DoubleItLogical.wsdl
@@ -139,4 +139,9 @@
             <wsdl:fault message="tns:DoubleItFault" name="DoubleItFault"/>
         </wsdl:operation>
     </wsdl:portType>
+    <wsdl:portType name="DoubleItOneWayPortType">
+        <wsdl:operation name="DoubleIt">
+            <wsdl:input message="tns:DoubleItRequest"/>
+        </wsdl:operation>
+    </wsdl:portType>
 </wsdl:definitions>
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 feb8804..868aa44 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
@@ -73,6 +73,17 @@
             </wsdl:fault>
         </wsdl:operation>
     </wsdl:binding>
+    <wsdl:binding name="DoubleItSymmetricAddressingOneWayBinding" type="tns:DoubleItOneWayPortType">
+        <wsp:PolicyReference URI="#DoubleItSymmetricAddressingPolicy"/>
+        <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="#DoubleItBinding_DoubleIt_Input_Policy"/>
+            </wsdl:input>
+        </wsdl:operation>
+    </wsdl:binding>
     <wsdl:binding name="DoubleItKeyIdentifierDerivedBinding" type="tns:DoubleItPortType">
         <wsp:PolicyReference URI="#DoubleItKeyIdentifierDerivedPolicy"/>
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -669,6 +680,9 @@
         <wsdl:port name="DoubleItSymmetricAddressingPort" binding="tns:DoubleItSymmetricAddressingBinding">
             <soap:address location="http://localhost:9001/DoubleItX509SymmetricAddressing"/>
         </wsdl:port>
+        <wsdl:port name="DoubleItSymmetricAddressingOneWayPort" binding="tns:DoubleItSymmetricAddressingOneWayBinding">
+            <soap:address location="http://localhost:9001/DoubleItX509SymmetricAddressingOneWay"/>
+        </wsdl:port>
         <wsdl:port name="DoubleItKeyIdentifierDerivedPort" binding="tns:DoubleItKeyIdentifierDerivedBinding">
             <soap:address location="http://localhost:9001/DoubleItX509KeyIdentifierDerived"/>
         </wsdl:port>
@@ -828,7 +842,7 @@
     <wsp:Policy wsu:Id="DoubleItSymmetricAddressingPolicy">
         <wsp:ExactlyOne>
             <wsp:All>
-                <wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"
wsp:Optional="true"/>
+                <wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"
wsp:Optional="false"/>
                 <sp:SymmetricBinding>
                     <wsp:Policy>
                         <sp:ProtectionToken>
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 6716798..2bf31bd 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
@@ -47,6 +47,12 @@
             <entry key="security.encryption.username" value="bob"/>
         </jaxws:properties>
     </jaxws:client>
+    <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSymmetricAddressingOneWayPort"
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}DoubleItKeyIdentifierDerivedPort"
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 7c4f2d9..4568794 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
@@ -63,6 +63,12 @@
             <entry key="security.signature.crypto" value-ref="crypto"/>
         </jaxws:properties>
     </jaxws:endpoint>
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="SymmetricAddressingOneWay"
address="http://localhost:${testutil.ports.x509.Server}/DoubleItX509SymmetricAddressingOneWay"
serviceName="s:DoubleItService" endpointName="s:DoubleItSymmetricAddressingOneWayPort" implementor="org.apache.cxf.systest.ws.common.DoubleItOneWayImpl"
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.crypto" value-ref="crypto"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
     <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="KeyIdentifierDerived"
address="http://localhost:${testutil.ports.x509.Server}/DoubleItX509KeyIdentifierDerived"
serviceName="s:DoubleItService" endpointName="s:DoubleItKeyIdentifierDerivedPort" 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 870fd9c..deaf873 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
@@ -66,6 +66,13 @@
             <entry key="ws-security.enable.streaming" value="true"/>
         </jaxws:properties>
     </jaxws:endpoint>
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="SymmetricAddressingOneWay"
address="http://localhost:${testutil.ports.x509.StaxServer}/DoubleItX509SymmetricAddressingOneWay"
serviceName="s:DoubleItService" endpointName="s:DoubleItSymmetricAddressingOneWayPort" implementor="org.apache.cxf.systest.ws.common.DoubleItOneWayImpl"
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.crypto" value-ref="crypto"/>
+            <entry key="ws-security.enable.streaming" value="true"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
     <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="KeyIdentifierDerived"
address="http://localhost:${testutil.ports.x509.StaxServer}/DoubleItX509KeyIdentifierDerived"
serviceName="s:DoubleItService" endpointName="s:DoubleItKeyIdentifierDerivedPort" 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"/>

-- 
To stop receiving notification emails like this one, please contact
coheigea@apache.org.

Mime
View raw message