Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9EBEA19754 for ; Wed, 13 Apr 2016 15:39:38 +0000 (UTC) Received: (qmail 7391 invoked by uid 500); 13 Apr 2016 15:39:38 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 7240 invoked by uid 500); 13 Apr 2016 15:39:38 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 7195 invoked by uid 99); 13 Apr 2016 15:39:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Apr 2016 15:39:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3F421DFDCF; Wed, 13 Apr 2016 15:39:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Date: Wed, 13 Apr 2016 15:39:38 -0000 Message-Id: <746d6d12705a414abfcba2055d327d55@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cxf-fediz git commit: Added SSO test for IdP Repository: cxf-fediz Updated Branches: refs/heads/1.2.x-fixes 0821461a0 -> 7fb519c25 Added SSO test for IdP Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/9779277b Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/9779277b Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/9779277b Branch: refs/heads/1.2.x-fixes Commit: 9779277b57ee3469edbcc4b89f922cc43df69e1f Parents: 0821461 Author: Colm O hEigeartaigh Authored: Wed Apr 13 15:09:33 2016 +0100 Committer: Colm O hEigeartaigh Committed: Wed Apr 13 16:39:12 2016 +0100 ---------------------------------------------------------------------- .../apache/cxf/fediz/systests/idp/IdpTest.java | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/9779277b/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java ---------------------------------------------------------------------- diff --git a/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java b/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java index ca69583..a6b1e4e 100644 --- a/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java +++ b/systests/idp/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java @@ -47,6 +47,7 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.wss4j.dom.WSSConfig; import org.apache.xml.security.keys.KeyInfo; import org.apache.xml.security.signature.XMLSignature; +import org.apache.xml.security.utils.Base64; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -189,6 +190,72 @@ public class IdpTest { Assert.assertNotNull(wresult); } + + @org.junit.Test + public void testSuccessfulSSOInvokeOnIdP() throws Exception { + String url = "https://localhost:" + getIdpHttpsPort() + "/fediz-idp/federation?"; + url += "wa=wsignin1.0"; + url += "&whr=urn:org:apache:cxf:fediz:idp:realm-A"; + url += "&wtrealm=urn:org:apache:cxf:fediz:fedizhelloworld"; + String wreply = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet"; + url += "&wreply=" + wreply; + + String user = "alice"; + String password = "ecila"; + + final WebClient webClient = new WebClient(); + webClient.getOptions().setUseInsecureSSL(true); + webClient.addRequestHeader("Authorization", "Basic " + Base64.encode((user + ":" + password).getBytes())); + + // + // First invocation + // + + webClient.getOptions().setJavaScriptEnabled(false); + HtmlPage idpPage = webClient.getPage(url); + webClient.getOptions().setJavaScriptEnabled(true); + Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText()); + + // Parse the form to get the token (wresult) + DomNodeList results = idpPage.getElementsByTagName("input"); + + String wresult = null; + for (DomElement result : results) { + if ("wresult".equals(result.getAttributeNS(null, "name"))) { + wresult = result.getAttributeNS(null, "value"); + break; + } + } + + Assert.assertNotNull(wresult); + + // + // Second invocation - change the credentials to make sure the session is set up correctly + // + + webClient.removeRequestHeader("Authorization"); + webClient.addRequestHeader("Authorization", "Basic " + Base64.encode(("mallory" + ":" + password).getBytes())); + + webClient.getOptions().setJavaScriptEnabled(false); + idpPage = webClient.getPage(url); + webClient.getOptions().setJavaScriptEnabled(true); + Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText()); + + // Parse the form to get the token (wresult) + results = idpPage.getElementsByTagName("input"); + + wresult = null; + for (DomElement result : results) { + if ("wresult".equals(result.getAttributeNS(null, "name"))) { + wresult = result.getAttributeNS(null, "value"); + break; + } + } + + Assert.assertNotNull(wresult); + + webClient.close(); + } @Test public void testIdPMetadata() throws Exception {