[java-idp-integration-tests] 05/07: Enable consent for IdP V4

Tom Zeller tzeller at dragonacea.biz
Wed May 5 20:46:43 UTC 2021


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

tzeller pushed a commit to branch main
in repository java-idp-integration-tests.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=0ecde0e3df03cc230e2cb84e00863b94936446a3

commit 0ecde0e3df03cc230e2cb84e00863b94936446a3
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed May 5 15:08:04 2021 -0500

    Enable consent for IdP V4
    
    https://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=6bc4dccf74df9034986a3291c6373dccda66e777
---
 .../shibboleth/idp/test/BaseIntegrationTest.java   |  8 +++++
 .../test/saml1/AbstractSAML1IntegrationTest.java   | 34 +++++++++++++++++-----
 .../test/saml2/AbstractSAML2IntegrationTest.java   | 18 ++++++++++++
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 1909cdf..23ac2ba 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -1260,6 +1260,14 @@ public abstract class BaseIntegrationTest
         replaceIdPHomeFile(pathToLogbackXML, oldText, newText);
     }
 
+    public void enableAttributeReleaseConsent() throws IOException {
+        final Path pathToRelyingPartyXML = Paths.get("conf", "relying-party.xml");
+
+        final String oldText = "<bean parent=\"SAML2.SSO\" />";
+        final String newText = "<bean parent=\"SAML2.SSO\" p:postAuthenticationFlows=\"attribute-release\" />";
+        replaceIdPHomeFile(pathToRelyingPartyXML, oldText, newText);
+    }
+
     /**
      * Use attribute-resolver-ldap.xml instead of attribute-resolver.xml.
      * 
diff --git a/src/test/java/net/shibboleth/idp/test/saml1/AbstractSAML1IntegrationTest.java b/src/test/java/net/shibboleth/idp/test/saml1/AbstractSAML1IntegrationTest.java
index c7670ea..fef5e70 100644
--- a/src/test/java/net/shibboleth/idp/test/saml1/AbstractSAML1IntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/saml1/AbstractSAML1IntegrationTest.java
@@ -36,6 +36,7 @@ import org.opensaml.core.xml.io.UnmarshallingException;
 import org.opensaml.saml.saml1.core.AuthenticationStatement;
 import org.opensaml.saml.saml1.core.Response;
 import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -102,21 +103,40 @@ public class AbstractSAML1IntegrationTest extends BaseIntegrationTest {
         // Uncomment disabled by default AttributeQuery profile
         final StringBuilder toUncomment = new StringBuilder();
         toUncomment.append("\\<\\!--\\s+");
+        if (idpVersion.startsWith("3") || idpVersion.startsWith("4.0")) {
         toUncomment.append("<bean parent=\"Shibboleth.SSO\" p:postAuthenticationFlows=\"attribute-release\" />");
+        } else {
+            toUncomment.append("<bean parent=\"Shibboleth.SSO\" />");    
+        }
         toUncomment.append("\\s+");
         toUncomment.append("<ref bean=\"SAML1.AttributeQuery\" />");
         toUncomment.append("\\s+");
         toUncomment.append("<ref bean=\"SAML1.ArtifactResolution\" />");
         toUncomment.append("\\s+--\\>");
 
-        final StringBuilder commented = new StringBuilder();
-        commented.append("<bean parent=\"Shibboleth.SSO\" p:postAuthenticationFlows=\"attribute-release\" />");
-        commented.append(System.lineSeparator());
-        commented.append("<ref bean=\"SAML1.AttributeQuery\" />");
-        commented.append(System.lineSeparator());
-        commented.append("<ref bean=\"SAML1.ArtifactResolution\" />");
+        final StringBuilder uncommented = new StringBuilder();
+        uncommented.append("<bean parent=\"Shibboleth.SSO\" p:postAuthenticationFlows=\"attribute-release\" />");
+        uncommented.append(System.lineSeparator());
+        uncommented.append("<ref bean=\"SAML1.AttributeQuery\" />");
+        uncommented.append(System.lineSeparator());
+        uncommented.append("<ref bean=\"SAML1.ArtifactResolution\" />");
+
+        replaceFile(pathToRelyingPartyXML, toUncomment.toString(), uncommented.toString());
+    }
 
-        replaceFile(pathToRelyingPartyXML, toUncomment.toString(), commented.toString());
+    /**
+     * Enable consent to attribute release for IdP versions 4.1 and later.
+     * 
+     * Attribute consent was enabled by default for IdP versions 3 through 4.0.
+     * 
+     * @throws IOException if an I/O error occurs
+     */
+    @BeforeClass
+    public void setUpAttributeConsent() throws IOException {
+        if (idpVersion.startsWith("3") || idpVersion.startsWith("4.0")) {
+        } else {
+            enableAttributeReleaseConsent();
+        }
     }
 
     /**
diff --git a/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java b/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
index 0656168..02fa67f 100644
--- a/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
@@ -50,6 +50,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -77,6 +78,23 @@ public abstract class AbstractSAML2IntegrationTest extends BaseIntegrationTest {
     /** ID of transient ID input element to init logout. */
     @Nonnull public String logoutTransientIDInputID;
 
+    @BeforeClass
+    /**
+     * Enable consent to attribute release for IdP versions 4.1 and later.
+     * 
+     * Attribute consent was enabled by default for IdP versions 3 through 4.0.
+     * 
+     * @throws IOException if an I/O error occurs
+     */
+    public void setUpAttributeConsent() throws IOException {
+        if (idpVersion.startsWith("3") || idpVersion.startsWith("4.0")) {
+            log.debug("Not enabling attribute-release consent for IdP version '{}'", idpVersion);
+        } else {
+            log.debug("Enabling attribute-release consent for IdP version '{}'", idpVersion);
+            enableAttributeReleaseConsent();
+        }
+    }
+
     /**
      * Setup response validator.
      * 

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


More information about the commits mailing list