Repository: cxf-fediz Updated Branches: refs/heads/master ccb7a08e8 -> 3957617a1
Adding a test for the logout issue Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/3957617a Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/3957617a Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/3957617a Branch: refs/heads/master Commit: 3957617a18e6eea33b890739f2e8609aef806b0f Parents: ccb7a08 Author: Colm O hEigeartaigh <[email protected]> Authored: Mon Apr 13 16:37:03 2015 +0100 Committer: Colm O hEigeartaigh <[email protected]> Committed: Mon Apr 13 16:37:03 2015 +0100 ---------------------------------------------------------------------- .../main/webapp/WEB-INF/idp-config-realmb.xml | 1 + .../fediz/integrationtests/AbstractTests.java | 39 ++++++++++++++++++++ .../fediz/integrationtests/HTTPTestUtils.java | 21 +++++++++++ 3 files changed, 61 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/3957617a/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml ---------------------------------------------------------------------- diff --git a/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml b/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml index 00faa08..6cd555d 100644 --- a/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml +++ b/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml @@ -85,6 +85,7 @@ <property name="serviceDisplayName" value="REALM B" /> <property name="serviceDescription" value="IDP of Realm B" /> <property name="rpSingleSignOutConfirmation" value="true"/> + <property name="rpSingleSignOutCleanupConfirmation" value="false"/> </bean> <bean id="idp-realmA" class="org.apache.cxf.fediz.service.idp.model.ServiceConfig"> http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/3957617a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java ---------------------------------------------------------------------- diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java index 210afa3..d27b08e 100644 --- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java +++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java @@ -447,6 +447,45 @@ public abstract class AbstractTests { } @org.junit.Test + public void testIdPLogoutCleanup() throws Exception { + + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; + String user = "alice"; + String password = "ecila"; + + CookieManager cookieManager = new CookieManager(); + + // 1. Login + HTTPTestUtils.loginWithCookieManager(url, user, password, getIdpHttpsPort(), cookieManager); + + // 2. Now we should have a cookie from the RP and IdP and should be able to do + // subsequent requests without authenticate again. Lets test this first. + WebClient webClient = new WebClient(); + webClient.setCookieManager(cookieManager); + webClient.getOptions().setUseInsecureSSL(true); + final HtmlPage rpPage = webClient.getPage(url); + Assert.assertEquals("WS Federation Systests Examples", rpPage.getTitleText()); + + // 3. now we logout from IdP + String idpLogoutUrl = "https://localhost:" + getIdpHttpsPort() + "/fediz-idp/federation?wa=" + + FederationConstants.ACTION_SIGNOUT_CLEANUP; + + HTTPTestUtils.logoutCleanup(idpLogoutUrl, cookieManager); + + // 4. now we try to access the RP and idp without authentication but with the existing cookies + // to see if we are really logged out + String rpUrl = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; + + webClient = new WebClient(); + webClient.setCookieManager(cookieManager); + webClient.getOptions().setUseInsecureSSL(true); + webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); + final HtmlPage idpPage = webClient.getPage(rpUrl); + + Assert.assertEquals(401, idpPage.getWebResponse().getStatusCode()); + } + + @org.junit.Test public void testAliceModifiedSignature() throws Exception { String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; String user = "alice"; http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/3957617a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java ---------------------------------------------------------------------- diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java index d05fed6..d6436b0 100644 --- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java +++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java @@ -121,5 +121,26 @@ public final class HTTPTestUtils { webClient.getPage(imgSrc); } } + + public static void logoutCleanup(String url, CookieManager cookieManager) throws IOException { + final WebClient webClient = new WebClient(); + webClient.setCookieManager(cookieManager); + webClient.getOptions().setUseInsecureSSL(true); + final HtmlPage idpPage = webClient.getPage(url); + + Assert.assertEquals("IDP SignOut Response Page", idpPage.getTitleText()); + + Assert.assertTrue(idpPage.asText().contains("CXF Fediz IDP successful logout")); + + DomNodeList<DomElement> images = idpPage.getElementsByTagName("img"); + Assert.assertEquals(1, images.getLength()); + for (int i = 0; i < images.size(); i++) { + DomElement domElement = images.get(i); + String imgSrc = domElement.getAttribute("src"); + + //we should get a fault if the image isn't available. + webClient.getPage(imgSrc); + } + } }
