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 2016/01/06 12:32:37 UTC

cxf git commit: Adding another secured fault test

Repository: cxf
Updated Branches:
  refs/heads/master 19b53fc0d -> fa985a4e4


Adding another secured fault test


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fa985a4e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fa985a4e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fa985a4e

Branch: refs/heads/master
Commit: fa985a4e4da2059e68635e5e1c538ae46a03643c
Parents: 19b53fc
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Wed Jan 6 11:32:02 2016 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed Jan 6 11:32:02 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/systest/ws/fault/FaultTest.java  | 35 +++++++++++
 .../cxf/systest/ws/fault/DoubleItFault.wsdl     | 66 ++++++++++++++++++++
 .../org/apache/cxf/systest/ws/fault/client.xml  |  8 +++
 .../org/apache/cxf/systest/ws/fault/server.xml  |  6 ++
 4 files changed, 115 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fa985a4e/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
index 4bc825b..9a27fc5 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
@@ -225,4 +225,39 @@ public class FaultTest extends AbstractBusClientServerTestBase {
         client.destroy();
     }
     
+    @org.junit.Test
+    public void testSoap11PolicyWithParts() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = FaultTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItSoap11PolicyWithPartsPort");
+        DoubleItPortType utPort = 
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(utPort, PORT);
+        
+        // Make a successful invocation
+        ((BindingProvider)utPort).getRequestContext().put("security.username", "alice");
+        utPort.doubleIt(25);
+        
+        // Now make an invocation using another username
+        ((BindingProvider)utPort).getRequestContext().put("security.username", "bob");
+        ((BindingProvider)utPort).getRequestContext().put("security.password", "password");
+        try {
+            utPort.doubleIt(25);
+            fail("Expected failure on bob");
+        } catch (Exception ex) {
+            assertTrue(ex.getMessage().contains("This is a fault"));
+        }
+        
+        ((java.io.Closeable)utPort).close();
+        bus.shutdown(true);
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/fa985a4e/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
index 2d4bf02..df7ffe1 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
@@ -93,6 +93,21 @@
             </wsdl:fault>
         </wsdl:operation>
     </wsdl:binding>
+    <wsdl:binding name="DoubleItSoap11NoPolicyBinding" 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"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="DoubleItFault">
+                <soap:fault use="literal" name="DoubleItFault"/>
+            </wsdl:fault>
+        </wsdl:operation>
+    </wsdl:binding>
     <wsdl:service name="DoubleItService">
         <wsdl:port name="DoubleItSoap11Port" binding="tns:DoubleItSoap11Binding">
             <soap:address location="http://localhost:9009/DoubleItSoap11"/>
@@ -109,6 +124,10 @@
         <wsdl:port name="DoubleItAsymmetricPort" binding="tns:DoubleItAsymmetricBinding">
             <soap12:address location="http://localhost:9009/DoubleItAsymmetric"/>
         </wsdl:port>
+        <wsdl:port name="DoubleItSoap11PolicyWithPartsPort" binding="tns:DoubleItSoap11NoPolicyBinding">
+            <wsp:PolicyReference URI="#DoubleItPlaintextWithPartsPolicy"/>
+            <soap:address location="http://localhost:9009/DoubleItSoap11PolicyWithParts"/>
+        </wsdl:port>
     </wsdl:service>
     <wsp:Policy wsu:Id="DoubleItPlaintextPolicy">
         <wsp:ExactlyOne>
@@ -193,6 +212,53 @@
             </wsp:All>
         </wsp:ExactlyOne>
     </wsp:Policy>
+    <wsp:Policy wsu:Id="DoubleItPlaintextWithPartsPolicy">
+        <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:RequireKeyIdentifierReference/>
+                                    </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>
+                <sp:SupportingTokens>
+                    <wsp:Policy>
+                        <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
+                            <wsp:Policy>
+                                <sp:WssUsernameToken10/>
+                            </wsp:Policy>
+                        </sp:UsernameToken>
+                    </wsp:Policy>
+                </sp:SupportingTokens>
+                <sp:EncryptedParts>
+                    <sp:Body/>
+                </sp:EncryptedParts>
+                <sp:SignedParts>
+                    <sp:Body/>
+                </sp:SignedParts>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
     <wsp:Policy wsu:Id="DoubleItBinding_DoubleIt_Input_Policy">
         <wsp:ExactlyOne>
             <wsp:All>

http://git-wip-us.apache.org/repos/asf/cxf/blob/fa985a4e/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
index 8863d41..b22bb4d 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
@@ -56,4 +56,12 @@
             <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}DoubleItSoap11PolicyWithPartsPort" createdFromAPI="true">
+        <jaxws:properties>
+            <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+            <entry key="security.encryption.properties" value="bob.properties"/>
+            <entry key="security.encryption.username" value="bob"/>
+        </jaxws:properties>
+    </jaxws:client>
 </beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/fa985a4e/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
index 3362cab..6fb8461 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
@@ -50,4 +50,10 @@
             <entry key="mtom-enabled" value="true"/>
         </jaxws:properties>
     </jaxws:endpoint>
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="Soap11PolicyWithParts" address="http://localhost:${testutil.ports.fault.Server}/DoubleItSoap11PolicyWithParts" serviceName="s:DoubleItService" endpointName="s:DoubleItSoap11PolicyWithPartsPort" implementor="org.apache.cxf.systest.ws.fault.DoubleItPortTypeImpl" wsdlLocation="org/apache/cxf/systest/ws/fault/DoubleItFault.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>
 </beans>