[java-shib-metadata] branch main updated: Add test for remove-only case of NameIDFormat filter.
Codeberg
noreply at shibboleth.net
Tue Jan 20 20:11:46 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-shib-metadata.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-metadata/commit/3a908050dd50d621ce5604a0a47699b60a6cb810
The following commit(s) were added to refs/heads/main by this push:
new 3a908050 Add test for remove-only case of NameIDFormat filter.
3a908050 is described below
commit 3a908050dd50d621ce5604a0a47699b60a6cb810
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jan 20 15:11:36 2026 -0500
Add test for remove-only case of NameIDFormat filter.
---
.../filter/NameIDFormatFilterParserTest.java | 34 ++++++++++++-----
.../metadata/filter/nameIDFormatRemoveOnly.xml | 43 ++++++++++++++++++++++
2 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/filter/NameIDFormatFilterParserTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/filter/NameIDFormatFilterParserTest.java
index 7dece2a7..8ee2c43e 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/filter/NameIDFormatFilterParserTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/filter/NameIDFormatFilterParserTest.java
@@ -37,20 +37,26 @@ public class NameIDFormatFilterParserTest extends AbstractMetadataParserTest {
@Test
public void test() throws ResolverException, IOException {
- doTest("filter/nameIDFormat.xml");
+ doTest(false, "filter/nameIDFormat.xml");
}
@Test
public void testRegex() throws ResolverException, IOException {
- doTest("filter/nameIDFormatRegex.xml");
+ doTest(false, "filter/nameIDFormatRegex.xml");
}
@Test
public void testWithScript() throws ResolverException, IOException {
- doTest("filter/nameIDFormatWithScript.xml");
+ doTest(false, "filter/nameIDFormatWithScript.xml");
}
- private void doTest(final String... files) throws ResolverException, IOException {
+ @Test
+ public void testRemoveOnly() throws ResolverException, IOException {
+ doTest(true, "filter/nameIDFormatRemoveOnly.xml");
+
+ }
+
+ private void doTest(boolean removeOnly, final String... files) throws ResolverException, IOException {
final MetadataResolver resolver = getBean(MetadataResolver.class, files);
final NameIDFormatFilter filter = (NameIDFormatFilter) resolver.getMetadataFilter();
@@ -63,9 +69,13 @@ public class NameIDFormatFilterParserTest extends AbstractMetadataParserTest {
SPSSODescriptor role = entity.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
assert role != null;
-
- Assert.assertEquals(role.getNameIDFormats().size(), 1);
- Assert.assertEquals(role.getNameIDFormats().get(0).getURI(), "foo");
+
+ if (removeOnly) {
+ Assert.assertTrue(role.getNameIDFormats().isEmpty());
+ } else {
+ Assert.assertEquals(role.getNameIDFormats().size(), 1);
+ Assert.assertEquals(role.getNameIDFormats().get(0).getURI(), "foo");
+ }
key = new EntityIdCriterion("https://sp2.example.org/sp/shibboleth");
entity = resolver.resolveSingle(new CriteriaSet(key));
@@ -74,9 +84,13 @@ public class NameIDFormatFilterParserTest extends AbstractMetadataParserTest {
role = entity.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
assert role != null;
- Assert.assertEquals(role.getNameIDFormats().size(), 2);
- Assert.assertEquals(role.getNameIDFormats().get(0).getURI(), "foo");
- Assert.assertEquals(role.getNameIDFormats().get(1).getURI(), "bar");
+ if (removeOnly) {
+ Assert.assertTrue(role.getNameIDFormats().isEmpty());
+ } else {
+ Assert.assertEquals(role.getNameIDFormats().size(), 2);
+ Assert.assertEquals(role.getNameIDFormats().get(0).getURI(), "foo");
+ Assert.assertEquals(role.getNameIDFormats().get(1).getURI(), "bar");
+ }
}
}
\ No newline at end of file
diff --git a/shib-metadata-spring/src/test/resources/net/shibboleth/spring/metadata/filter/nameIDFormatRemoveOnly.xml b/shib-metadata-spring/src/test/resources/net/shibboleth/spring/metadata/filter/nameIDFormatRemoveOnly.xml
new file mode 100644
index 00000000..a47780b6
--- /dev/null
+++ b/shib-metadata-spring/src/test/resources/net/shibboleth/spring/metadata/filter/nameIDFormatRemoveOnly.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata:MetadataProvider xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:metadata="urn:mace:shibboleth:2.0:metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
+ urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
+
+ failFastInitialization="false" requireValidMetadata="false"
+
+ id="nameIDFormat" xsi:type="metadata:InlineMetadataProvider">
+ <metadata:MetadataFilter xsi:type="metadata:NameIDFormat" removeExistingFormats="true">
+ <metadata:Entity>https://sp.example.org/sp/shibboleth</metadata:Entity>
+ <metadata:Entity>https://sp4.example.org/sp/shibboleth</metadata:Entity>
+ <metadata:Entity>https://sp2.example.org/sp/shibboleth</metadata:Entity>
+ </metadata:MetadataFilter>
+
+ <EntitiesDescriptor Name="ukgroup">
+ <EntityDescriptor ID="uk001502"
+ entityID="https://sp.example.org/sp/shibboleth">
+
+ <SPSSODescriptor
+ protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
+
+ <AssertionConsumerService
+ Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
+ Location="https://sp.example.org/Shibboleth.sso/SAML2/POST-SimpleSign"
+ index="5" />
+ </SPSSODescriptor>
+ </EntityDescriptor>
+
+ <EntityDescriptor ID="uk001503"
+ entityID="https://sp2.example.org/sp/shibboleth">
+
+ <SPSSODescriptor
+ protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
+ <NameIDFormat>baz</NameIDFormat>
+ <AssertionConsumerService
+ Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
+ Location="https://sp2.example.org/Shibboleth.sso/SAML2/POST-SimpleSign"
+ index="5" />
+ </SPSSODescriptor>
+ </EntityDescriptor>
+ </EntitiesDescriptor>
+</metadata:MetadataProvider>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list