[java-metadata-aggregator] 02/02: MDA-65 - Catch up on unit tests

Ian Young ian at iay.org.uk
Tue May 11 16:04:16 UTC 2021


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

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=fd58a42ea906c8c4c9d2cab09c933702825abe20

commit fd58a42ea906c8c4c9d2cab09c933702825abe20
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Tue May 11 17:02:37 2021 +0100

    MDA-65 - Catch up on unit tests
    
    https://issues.shibboleth.net/jira/browse/MDA-65
---
 .../metadata/dom/saml/GenerateIdStageTest.java     | 42 ++++++++++++++++-
 .../metadata/dom/saml/GenerateIdStage-in.xml       | 52 ++++++++++++++++++++++
 .../dom/saml/GenerateIdStage-notentity.xml         |  2 +
 3 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/GenerateIdStageTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/GenerateIdStageTest.java
index 09df337..385c5be 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/GenerateIdStageTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/GenerateIdStageTest.java
@@ -28,7 +28,9 @@ import java.util.regex.Pattern;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.dom.BaseDOMTest;
 import net.shibboleth.metadata.dom.DOMElementItem;
+import net.shibboleth.utilities.java.support.security.impl.FixedStringIdentifierGenerationStrategy;
 import net.shibboleth.utilities.java.support.xml.BasicParserPool;
 import net.shibboleth.utilities.java.support.xml.ElementSupport;
 
@@ -37,7 +39,12 @@ import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class GenerateIdStageTest {
+public class GenerateIdStageTest extends BaseDOMTest {
+
+
+    protected GenerateIdStageTest() {
+        super(GenerateIdStage.class);
+    }
 
     /**
      * Test for MDA-90 (default identifier strategy used by GenerateIdStage
@@ -92,4 +99,37 @@ public class GenerateIdStageTest {
         Assert.assertEquals(values.size(), howMany);
     }
 
+    @Test
+    public void testExplicitConstructor() throws Exception {
+        final var strat = new FixedStringIdentifierGenerationStrategy("hello");
+
+        final var stage = new GenerateIdStage(strat);
+        stage.setId("test");
+        stage.initialize();
+        
+        final var item = readDOMItem("in.xml");
+        
+        stage.execute(List.of(item));
+        
+        stage.destroy();
+        
+        Assert.assertEquals(item.unwrap().getAttribute("ID"), "hello");
+    }
+    
+    @Test
+    public void testNotSAMLEntity() throws Exception {
+        final var strat = new FixedStringIdentifierGenerationStrategy("hello");
+
+        final var stage = new GenerateIdStage(strat);
+        stage.setId("test");
+        stage.initialize();
+        
+        final var item = readDOMItem("notentity.xml");
+        
+        stage.execute(List.of(item));
+        
+        stage.destroy();
+        
+        Assert.assertEquals(item.unwrap().getAttribute("ID"), "original");
+    }
 }
diff --git a/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-in.xml b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-in.xml
new file mode 100644
index 0000000..6e49de0
--- /dev/null
+++ b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-in.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport"
+    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+    xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol"
+    xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init" xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
+    xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
+    xmlns:ukfedlabel="http://ukfederation.org.uk/2006/11/label" xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    ID="uk002232" entityID="https://example.org/entity">
+    <Extensions>
+        <ukfedlabel:UKFederationMember/>
+        <ukfedlabel:Software date="2013-08-28" fullVersion="2.5.1" name="Shibboleth" version="2"/>
+        <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
+        <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#sha384"/>
+        <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+        <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#sha224"/>
+        <alg:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha384"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2009/xmldsig11#dsa-sha256"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
+        <alg:SigningMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/>
+    </Extensions>
+    <SPSSODescriptor
+        protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:1.0:protocol">
+        <Extensions>
+            <init:RequestInitiator Binding="urn:oasis:names:tc:SAML:profiles:SSO:request-init"
+                Location="https://example.org/sso/Shibboleth.sso/Login"/>
+            <idpdisc:DiscoveryResponse Binding="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol"
+                Location="https://example.org/sso/Shibboleth.sso/Login" index="1"/>
+        </Extensions>
+        <ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP"
+            Location="https://example.org/sso/Shibboleth.sso/Artifact/SOAP" index="1"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
+            Location="https://example.org/sso/Shibboleth.sso/SAML2/POST" index="1"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
+            Location="https://example.org/sso/Shibboleth.sso/SAML2/POST-SimpleSign" index="2"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact"
+            Location="https://example.org/sso/Shibboleth.sso/SAML2/Artifact" index="3"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:PAOS"
+            Location="https://example.org/sso/Shibboleth.sso/SAML2/ECP" index="4"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:1.0:profiles:browser-post"
+            Location="https://example.org/sso/Shibboleth.sso/SAML/POST" index="5"/>
+        <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:1.0:profiles:artifact-01"
+            Location="https://example.org/sso/Shibboleth.sso/SAML/Artifact" index="6"/>
+    </SPSSODescriptor>
+</EntityDescriptor>
diff --git a/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-notentity.xml b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-notentity.xml
new file mode 100644
index 0000000..c2a571c
--- /dev/null
+++ b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/GenerateIdStage-notentity.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<x ID="original"/>

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


More information about the commits mailing list