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 2016/12/08 11:46:34 UTC
cxf-fediz git commit: Fixing ForceAuthn SAML SSO tests
Repository: cxf-fediz
Updated Branches:
refs/heads/1.3.x-fixes 4f59dd2ec -> f8f5099b5
Fixing ForceAuthn SAML SSO tests
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/f8f5099b
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/f8f5099b
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/f8f5099b
Branch: refs/heads/1.3.x-fixes
Commit: f8f5099b5a81dfab262ef54b1f45314d0e1d0041
Parents: 4f59dd2
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Dec 8 11:15:43 2016 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Dec 8 11:46:28 2016 +0000
----------------------------------------------------------------------
.../apache/cxf/fediz/systests/idp/IdpTest.java | 45 +++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/f8f5099b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
----------------------------------------------------------------------
diff --git a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
index 86e9628..15a4dd9 100644
--- a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
+++ b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java
@@ -38,6 +38,7 @@ import javax.servlet.ServletException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebClient;
@@ -513,6 +514,8 @@ public class IdpTest {
String password = "ecila";
final WebClient webClient = new WebClient();
+ CookieManager cookieManager = new CookieManager();
+ webClient.setCookieManager(cookieManager);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getCredentialsProvider().setCredentials(
new AuthScope("localhost", Integer.parseInt(getIdpHttpsPort())),
@@ -562,8 +565,27 @@ public class IdpTest {
Assert.assertTrue(parsedResponse.contains(claim));
claim = ClaimTypes.EMAILADDRESS.toString();
Assert.assertTrue(parsedResponse.contains(claim));
-
+
webClient.close();
+
+ //
+ // Third invocation - create a new WebClient with no credentials (but with the same CookieManager)
+ // ...this should fail
+ //
+
+ WebClient newWebClient = new WebClient();
+ newWebClient.setCookieManager(cookieManager);
+ newWebClient.getOptions().setUseInsecureSSL(true);
+ newWebClient.getOptions().setJavaScriptEnabled(false);
+
+ try {
+ newWebClient.getPage(url);
+ Assert.fail("Failure expected on no credentials");
+ } catch (FailingHttpStatusCodeException ex) {
+ Assert.assertEquals(ex.getStatusCode(), 401);
+ }
+
+ newWebClient.close();
}
@org.junit.Test
@@ -621,6 +643,8 @@ public class IdpTest {
String password = "ecila";
final WebClient webClient = new WebClient();
+ CookieManager cookieManager = new CookieManager();
+ webClient.setCookieManager(cookieManager);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getCredentialsProvider().setCredentials(
new AuthScope("localhost", Integer.parseInt(getIdpHttpsPort())),
@@ -672,6 +696,25 @@ public class IdpTest {
Assert.assertTrue(parsedResponse.contains(claim));
webClient.close();
+
+ //
+ // Third invocation - create a new WebClient with no credentials (but with the same CookieManager)
+ // ...this should fail
+ //
+
+ WebClient newWebClient = new WebClient();
+ newWebClient.setCookieManager(cookieManager);
+ newWebClient.getOptions().setUseInsecureSSL(true);
+ newWebClient.getOptions().setJavaScriptEnabled(false);
+
+ try {
+ newWebClient.getPage(url);
+ Assert.fail("Failure expected on no credentials");
+ } catch (FailingHttpStatusCodeException ex) {
+ Assert.assertEquals(ex.getStatusCode(), 401);
+ }
+
+ newWebClient.close();
}
//