[java-idp-integration-tests] branch main updated: Override SAML1TestResponseValidator for IdP V4 tests

Tom Zeller tzeller at dragonacea.biz
Sun Sep 17 15:58:15 UTC 2023


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=892956deca1de0eea878e7b119788ac43ea0dcd8

The following commit(s) were added to refs/heads/main by this push:
     new 892956d  Override SAML1TestResponseValidator for IdP V4 tests
892956d is described below

commit 892956deca1de0eea878e7b119788ac43ea0dcd8
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Sun Sep 17 10:57:43 2023 -0500

    Override SAML1TestResponseValidator for IdP V4 tests
    
    Expect 4 attributes instead of 5 for IdP V4
    
    IDP-2173 - Schac rules do not include SAML 1 transcoder
    
    https://shibboleth.atlassian.net/browse/IDP-2173
---
 .../tests/saml1/AbstractSAML1IntegrationTest.java  |  2 +-
 .../tests/saml1/SAML1TestResponseValidator.java    | 92 ++++++++++++++++++++++
 2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/saml1/AbstractSAML1IntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/saml1/AbstractSAML1IntegrationTest.java
index 23d545e..5e75886 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/saml1/AbstractSAML1IntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/saml1/AbstractSAML1IntegrationTest.java
@@ -28,7 +28,6 @@ import javax.annotation.Nullable;
 
 import net.shibboleth.idp.integration.tests.BaseIntegrationTest;
 import net.shibboleth.idp.integration.tests.BrowserData;
-import net.shibboleth.idp.test.flows.saml1.SAML1TestResponseValidator;
 import net.shibboleth.shared.xml.XMLParserException;
 
 import org.opensaml.core.xml.io.Unmarshaller;
@@ -58,6 +57,7 @@ public class AbstractSAML1IntegrationTest extends BaseIntegrationTest {
     public void setUpValidator() throws IOException {
         validator = new SAML1TestResponseValidator();
         validator.authenticationMethod = AuthenticationStatement.PASSWORD_AUTHN_METHOD;
+        validator.idpVersion = idpVersion;
     }
 
     /**
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/saml1/SAML1TestResponseValidator.java b/src/test/java/net/shibboleth/idp/integration/tests/saml1/SAML1TestResponseValidator.java
new file mode 100644
index 0000000..811a424
--- /dev/null
+++ b/src/test/java/net/shibboleth/idp/integration/tests/saml1/SAML1TestResponseValidator.java
@@ -0,0 +1,92 @@
+
+package net.shibboleth.idp.integration.tests.saml1;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.saml.saml1.core.Attribute;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+
+/**
+ * Override SAML1TestResponseValidator from idp-conf-impl for IdP V4.
+ */
+public class SAML1TestResponseValidator extends net.shibboleth.idp.test.flows.saml1.SAML1TestResponseValidator {
+
+    /** IdP version determined from distribution name. **/
+    @Nullable public String idpVersion;
+
+    /** Class logger. */
+    @Nonnull private final Logger log = LoggerFactory.getLogger(SAML1TestResponseValidator.class);
+
+    /**
+     * Expect 4 attributes instead of 5 for IdP V4.
+     * 
+     * {@inheritDoc}
+     */
+    @Override
+    public void assertAttributes(List<Attribute> attributes) {
+        if (idpVersion != null && idpVersion.startsWith("4")) {
+            log.info("Expect 4 attributes instead of 5 for IdP V4");
+            assertAttributesV4(attributes);
+        } else {
+            super.assertAttributes(attributes);
+        }
+    }
+
+    /**
+     * Expect 4 attributes instead of 5 for IdP V4.
+     * 
+     * Copied from
+     * {@link net.shibboleth.idp.test.flows.saml1.SAML1TestResponseValidator#assertAttributes(List)}
+     */
+    public void assertAttributesV4(@Nullable final List<Attribute> attributes) {
+        assert attributes != null;
+        Assert.assertFalse(attributes.isEmpty());
+        Assert.assertEquals(attributes.size(), usedAttributeDesignators ? 2 : 4); // IdP V5 expects 5 attributes
+
+        // Ignore attribute ordering
+        final Map<String, Attribute> actualAttributes = new HashMap<>();
+        for (final Attribute attribute : attributes) {
+            actualAttributes.put(attribute.getAttributeName(), attribute);
+        }
+
+        if (usedAttributeDesignators) {
+            final Attribute actualMailAttribute = actualAttributes.get("urn:mace:dir:attribute-def:mail");
+            Assert.assertNotNull(actualMailAttribute);
+            assertAttribute(actualMailAttribute, "urn:mace:dir:attribute-def:mail", "jdoe at example.org");
+
+            // The scope here is in a separate XML attribute, so not in the element content.
+            final Attribute actualEPSAAttribute = actualAttributes
+                    .get("urn:mace:dir:attribute-def:eduPersonScopedAffiliation");
+            Assert.assertNotNull(actualEPSAAttribute);
+            assertAttribute(actualEPSAAttribute, "urn:mace:dir:attribute-def:eduPersonScopedAffiliation", "member");
+        } else {
+            final Attribute actualUidAttribute = actualAttributes.get("urn:mace:dir:attribute-def:uid");
+            Assert.assertNotNull(actualUidAttribute);
+            assertAttribute(actualUidAttribute, "urn:mace:dir:attribute-def:uid", "jdoe");
+
+            final Attribute actualMailAttribute = actualAttributes.get("urn:mace:dir:attribute-def:mail");
+            Assert.assertNotNull(actualMailAttribute);
+            assertAttribute(actualMailAttribute, "urn:mace:dir:attribute-def:mail", "jdoe at example.org");
+
+            // The scope here is in a separate XML attribute, so not in the element content.
+            final Attribute actualEPPNAttribute = actualAttributes
+                    .get("urn:mace:dir:attribute-def:eduPersonPrincipalName");
+            Assert.assertNotNull(actualEPPNAttribute);
+            assertAttribute(actualEPPNAttribute, "urn:mace:dir:attribute-def:eduPersonPrincipalName", "jdoe");
+
+            // The scope here is in a separate XML attribute, so not in the element content.
+            final Attribute actualEPSAAttribute = actualAttributes
+                    .get("urn:mace:dir:attribute-def:eduPersonScopedAffiliation");
+            Assert.assertNotNull(actualEPSAAttribute);
+            assertAttribute(actualEPSAAttribute, "urn:mace:dir:attribute-def:eduPersonScopedAffiliation", "member");
+        }
+    }
+
+}

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


More information about the commits mailing list