[java-identity-provider] branch master updated: Improve CAS proxy flow test.

Marvin S. Addison marvin.addison at gmail.com
Fri Nov 2 10:33:35 EDT 2018


This is an automated email from the git hooks/post-receive script.

serac pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=d039aceca5c5ce2427eb3321ea96c6fd6fd2c6a1

The following commit(s) were added to refs/heads/master by this push:
       new  d039ace   Improve CAS proxy flow test.
d039ace is described below

commit d039aceca5c5ce2427eb3321ea96c6fd6fd2c6a1
Author: Marvin S. Addison <serac at vt.edu>
AuthorDate: Fri Nov 2 10:32:24 2018 -0400

    Improve CAS proxy flow test.
    
    Extend HttpClientProxyValidator to cover more runtime code paths in test.
---
 .../idp/test/flows/cas/ProxyValidateFlowTest.java  |  4 +--
 .../test/flows/cas/ServiceValidateFlowTest.java    |  4 +--
 .../idp/test/flows/cas/TestProxyValidator.java     | 38 ++++++++++++++--------
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
index 26f6a29..355abf5 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
@@ -105,7 +105,7 @@ public class ProxyValidateFlowTest extends AbstractFlowTest {
         externalContext.getMockRequestParameterMap().put("ticket", ticket.getId());
         externalContext.getMockRequestParameterMap().put("pgtUrl", "https://proxy.example.com/");
 
-        testProxyValidator.setFailureFlag(false);
+        testProxyValidator.setResponseCode(200);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
 
@@ -129,7 +129,7 @@ public class ProxyValidateFlowTest extends AbstractFlowTest {
         externalContext.getMockRequestParameterMap().put("ticket", ticket.getId());
         externalContext.getMockRequestParameterMap().put("pgtUrl", "https://proxy.example.com/");
 
-        testProxyValidator.setFailureFlag(true);
+        testProxyValidator.setResponseCode(404);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
 
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
index 54ec48c..224bdc3 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
@@ -202,7 +202,7 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
         externalContext.getMockRequestParameterMap().put("ticket", ticket.getId());
         externalContext.getMockRequestParameterMap().put("pgtUrl", "https://proxy.example.com/");
 
-        testProxyValidator.setFailureFlag(false);
+        testProxyValidator.setResponseCode(200);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
 
@@ -232,7 +232,7 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
         externalContext.getMockRequestParameterMap().put("pgtUrl", "https://proxy.example.com/");
         overrideEndStateOutput(FLOW_ID, "ValidateSuccess");
 
-        testProxyValidator.setFailureFlag(true);
+        testProxyValidator.setResponseCode(404);
 
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
 
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/TestProxyValidator.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/TestProxyValidator.java
index e28f169..0e88230 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/TestProxyValidator.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/TestProxyValidator.java
@@ -17,32 +17,44 @@
 
 package net.shibboleth.idp.test.flows.cas;
 
-import net.shibboleth.idp.cas.proxy.ProxyValidator;
-import org.opensaml.profile.context.ProfileRequestContext;
+import net.shibboleth.idp.cas.proxy.impl.HttpClientProxyValidator;
+import net.shibboleth.idp.cas.service.Service;
+import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
+import org.opensaml.security.trust.TrustEngine;
+import org.opensaml.security.x509.X509Credential;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 import java.net.URI;
-import java.security.GeneralSecurityException;
 
 /**
  * Test proxy validator component.
  *
  * @author Marvin S. Addison
  */
-public class TestProxyValidator implements ProxyValidator {
+public class TestProxyValidator extends HttpClientProxyValidator {
+
+    /** Validation repsonse HTTP status code to return. */
+    private int responseCode;
 
-    /** Whether to fail or not. */
-    private boolean failureFlag;
+    /** Creates a new instance. */
+    public TestProxyValidator() {
+        super(new TrustEngine<X509Credential>() {
+            @Override
+            public boolean validate(
+                    @Nonnull final X509Credential x509Credential, @Nullable final CriteriaSet criteriaSet) {
+                return true;
+            }
+        });
+    }
 
-    public void setFailureFlag(final boolean isFail) {
-        this.failureFlag = isFail;
+    public void setResponseCode(final int code) {
+        this.responseCode = code;
     }
 
     @Override
-    public void validate(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final URI uri)
-            throws GeneralSecurityException {
-        if (failureFlag) {
-            throw new GeneralSecurityException("Proxy callback authentication failed (failureFlag==true)");
-        }
+    protected int connect(@Nonnull final URI uri, @Nonnull final Service service) {
+        return responseCode;
     }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list