Repository: cxf-fediz
Updated Branches:
  refs/heads/master 1858cb9e3 -> fe30273fd


Improve testing for SAML 1, holder of key, etc.


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

Branch: refs/heads/master
Commit: fe30273fdb62c1d6c3cf6a51ab343a9703e219a8
Parents: 1858cb9
Author: Colm O hEigeartaigh <cohei...@apache.org>
Authored: Thu Mar 5 11:27:56 2015 +0000
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Thu Mar 5 11:27:56 2015 +0000

----------------------------------------------------------------------
 .../fediz/integrationtests/HolderOfKeyTest.java | 16 +++++++
 .../cxf/fediz/integrationtests/WReqTest.java    | 47 +++++++++++++++++++-
 2 files changed, 61 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/fe30273f/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
----------------------------------------------------------------------
diff --git 
a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
 
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
index 32fbf35..2385ec7 100644
--- 
a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
+++ 
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
@@ -22,6 +22,8 @@ package org.apache.cxf.fediz.integrationtests;
 import java.io.File;
 
 import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.DomElement;
+import com.gargoylesoftware.htmlunit.html.DomNodeList;
 import com.gargoylesoftware.htmlunit.html.HtmlForm;
 import com.gargoylesoftware.htmlunit.html.HtmlPage;
 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
@@ -205,6 +207,20 @@ public class HolderOfKeyTest {
 
         final HtmlForm form = idpPage.getFormByName("signinresponseform");
         final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
+        
+        // Test the Subject Confirmation method here
+        DomNodeList<DomElement> 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.assertTrue(wresult != null 
+            && 
wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"));
+        
 
         final HtmlPage rpPage = button.click();
         Assert.assertEquals("WS Federation Systests Examples", 
rpPage.getTitleText());

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/fe30273f/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
----------------------------------------------------------------------
diff --git 
a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
 
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
index cf59ce7..b0a952d 100644
--- 
a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
+++ 
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
@@ -21,6 +21,14 @@ package org.apache.cxf.fediz.integrationtests;
 
 
 import java.io.File;
+import java.io.IOException;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.DomElement;
+import com.gargoylesoftware.htmlunit.html.DomNodeList;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleState;
@@ -28,6 +36,8 @@ import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.cxf.fediz.core.ClaimTypes;
 import org.apache.cxf.fediz.tomcat.FederationAuthenticator;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -185,8 +195,7 @@ public class WReqTest {
         String user = "alice";
         String password = "ecila";
         
-        final String bodyTextContent = 
-            HTTPTestUtils.login(url, user, password, getIdpHttpsPort());
+        final String bodyTextContent = login(url, user, password, 
getIdpHttpsPort());
         
         Assert.assertTrue("Principal not " + user,
                           bodyTextContent.contains("userPrincipal=" + user));
@@ -209,4 +218,38 @@ public class WReqTest {
 
     }
     
+    private static String login(String url, String user, String password, 
String idpPort) throws IOException {
+        final WebClient webClient = new WebClient();
+        webClient.getOptions().setUseInsecureSSL(true);
+        webClient.getCredentialsProvider().setCredentials(
+            new AuthScope("localhost", Integer.parseInt(idpPort)),
+            new UsernamePasswordCredentials(user, password));
+
+        webClient.getOptions().setJavaScriptEnabled(false);
+        final HtmlPage idpPage = webClient.getPage(url);
+        webClient.getOptions().setJavaScriptEnabled(true);
+        Assert.assertEquals("IDP SignIn Response Form", 
idpPage.getTitleText());
+        
+        // Test the SAML Version here
+        DomNodeList<DomElement> 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.assertTrue(wresult != null 
+            && wresult.contains("urn:oasis:names:tc:SAML:1.0:cm:bearer"));
+
+        final HtmlForm form = idpPage.getFormByName("signinresponseform");
+        final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
+
+        final HtmlPage rpPage = button.click();
+        Assert.assertEquals("WS Federation Systests Examples", 
rpPage.getTitleText());
+
+        return rpPage.getBody().getTextContent();
+    }
+    
 }

Reply via email to