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 2014/10/01 09:52:38 UTC

[5/8] git commit: Adding SAML Logout unit test + fixing bug

Adding SAML Logout unit test + fixing bug


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

Branch: refs/heads/master
Commit: 1b6058dbcde7da2a9a2924acb15b9bece2d72e6a
Parents: 5966160
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Sep 30 10:27:09 2014 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Sep 30 10:27:09 2014 +0100

----------------------------------------------------------------------
 .../fediz/core/processor/SAMLProcessorImpl.java  |  3 +--
 .../cxf/fediz/core/samlsso/SAMLRequestTest.java  | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1b6058db/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
index 0bb1fd8..64ffe36 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
@@ -40,7 +40,6 @@ import org.apache.cxf.fediz.core.SAMLSSOConstants;
 import org.apache.cxf.fediz.core.TokenValidator;
 import org.apache.cxf.fediz.core.TokenValidatorRequest;
 import org.apache.cxf.fediz.core.TokenValidatorResponse;
-import org.apache.cxf.fediz.core.config.FederationProtocol;
 import org.apache.cxf.fediz.core.config.FedizContext;
 import org.apache.cxf.fediz.core.config.SAMLProtocol;
 import org.apache.cxf.fediz.core.exception.ProcessingException;
@@ -411,7 +410,7 @@ public class SAMLProcessorImpl extends AbstractFedizProcessor {
 
         String redirectURL = null;
         try {
-            if (!(config.getProtocol() instanceof FederationProtocol)) {
+            if (!(config.getProtocol() instanceof SAMLProtocol)) {
                 LOG.error("Unsupported protocol");
                 throw new IllegalStateException("Unsupported protocol");
             }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1b6058db/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
index 3cab944..4293565 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
@@ -199,4 +199,23 @@ public class SAMLRequestTest {
         Assert.assertTrue(signature != null && signature.length() > 0);
     }
     
+    @org.junit.Test
+    public void createSAMLLogoutRequest() throws Exception {
+        // Mock up a Request
+        FedizContext config = getFederationConfigurator().getFedizContext("ROOT");
+        
+        HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
+        EasyMock.expect(req.getRequestURL()).andReturn(new StringBuffer(TEST_REQUEST_URL)).times(1, 2);
+        EasyMock.expect(req.getContextPath()).andReturn(TEST_REQUEST_URI);
+        EasyMock.expect(req.getRequestURI()).andReturn(TEST_REQUEST_URI).times(1, 2);
+        EasyMock.replay(req);
+        
+        FedizProcessor wfProc = new SAMLProcessorImpl();
+        RedirectionResponse response = wfProc.createSignOutRequest(req, config);
+        
+        String redirectionURL = response.getRedirectionURL();
+        Assert.assertTrue(redirectionURL.startsWith(TEST_IDP_ISSUER));
+        Assert.assertTrue(redirectionURL.endsWith("wa=wsignout1.0"));
+    }
+    
 }
\ No newline at end of file