cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Adding a WS-MEX unit test for the STS
Date Wed, 03 Jun 2015 11:12:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 4fec41d97 -> 02c588ce4


Adding a WS-MEX unit test for the STS


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

Branch: refs/heads/3.0.x-fixes
Commit: 02c588ce4ea5b26934da57cc920bfa13bdeceb98
Parents: 4fec41d
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Jun 3 12:00:51 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Jun 3 12:01:21 2015 +0100

----------------------------------------------------------------------
 .../systest/sts/issueunit/IssueUnitTest.java    | 37 +++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/02c588ce/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
index 34578c3..76a07cf 100644
--- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
+++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
@@ -25,13 +25,15 @@ import java.util.Map;
 import java.util.Properties;
 
 import javax.security.auth.callback.CallbackHandler;
+import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
-
 import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.context.WebServiceContextImpl;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.MessageImpl;
@@ -48,9 +50,13 @@ import org.apache.cxf.systest.sts.common.CommonCallbackHandler;
 import org.apache.cxf.systest.sts.common.SecurityTestUtil;
 import org.apache.cxf.systest.sts.deployment.STSServer;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.mex.MetadataExchange;
+import org.apache.cxf.ws.mex.model._2004_09.Metadata;
+import org.apache.cxf.ws.mex.model._2004_09.MetadataSection;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.tokenstore.SecurityToken;
 import org.apache.cxf.ws.security.trust.STSClient;
+import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.common.ext.WSSecurityException;
@@ -102,6 +108,35 @@ public class IssueUnitTest extends AbstractBusClientServerTestBase {
         SecurityTestUtil.cleanup();
         stopAllServers();
     }
+    
+    @org.junit.Test
+    public void testRetrieveWSMEX() throws Exception {
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = IssueUnitTest.class.getResource("cxf-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+  
+        // Get Metadata
+        JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+        proxyFac.setBindingId(SoapBindingConstants.SOAP11_BINDING_ID);
+        proxyFac.setAddress("https://localhost:" + STSPORT + "/SecurityTokenService/Transport/mex");
+        MetadataExchange exc = proxyFac.create(MetadataExchange.class);
+        Metadata metadata = exc.get2004();
+        
+        // Parse response (as per the STSClient)
+        Definition definition = null;
+        // Parse the MetadataSections into WSDL definition + associated schemas
+        for (MetadataSection s : metadata.getMetadataSection()) {
+            if ("http://schemas.xmlsoap.org/wsdl/".equals(s.getDialect())) {
+                definition = 
+                    bus.getExtension(WSDLManager.class).getDefinition((Element)s.getAny());
+            }
+        }
+        assertNotNull(definition);
+    }
 
     /**
      * Test the Symmetric Key SAML1 case


Mime
View raw message