[java-shib-profile] branch main updated: JSPROF-14 Tolerate gaps in resource-related module properties

Codeberg noreply at shibboleth.net
Thu Sep 17 18:34:20 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-profile.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-profile/commit/f39d0996ec330ffe1eeda22dba615bc4aa2e01a0

The following commit(s) were added to refs/heads/main by this push:
     new f39d099  JSPROF-14 Tolerate gaps in resource-related module properties
f39d099 is described below

commit f39d0996ec330ffe1eeda22dba615bc4aa2e01a0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Sep 17 19:34:24 2026 +0100

    JSPROF-14 Tolerate gaps in resource-related module properties
    
    https://shibboleth.atlassian.net/browse/JSPROF-14
    
    Add some unit tests for Installable Components.
---
 .../InstallableComponentTests.java                 | 142 +++++++++++++++++++++
 .../installablecomponent/testfile.properties       |  42 ++++++
 2 files changed, 184 insertions(+)

diff --git a/shib-profile-api/src/test/java/net/shibboleth/profile/installablecomponent/InstallableComponentTests.java b/shib-profile-api/src/test/java/net/shibboleth/profile/installablecomponent/InstallableComponentTests.java
new file mode 100644
index 0000000..6e16eae
--- /dev/null
+++ b/shib-profile-api/src/test/java/net/shibboleth/profile/installablecomponent/InstallableComponentTests.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.profile.installablecomponent;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.springframework.core.io.ClassPathResource;
+import org.testng.annotations.Test;
+
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.StringSupport;
+
+
+
+/**
+ * Tests for {@link InstallableComponentInfo} and {@link InstallableComponentSupport}
+ */
+public class InstallableComponentTests {
+    
+    /** The name of the component we pretend to be. */
+    static final private String PLUGIN_NAME = "net.shibboleth.idp.plugin.authn.totp";
+    
+    /** The properties file we load. */
+    private Properties properties;
+    
+    
+    /** The info we load. */
+    private InstallableComponentInfo info;
+    
+    @Test final void testLoadProperties() throws IOException {
+        
+        final ClassPathResource inputAsResource = new ClassPathResource("net/shibboleth/profile/installablecomponent/testfile.properties");
+        final String inputAsFQP = inputAsResource.getFile().getAbsolutePath();
+
+        properties = InstallableComponentSupport.loadInfo(CollectionSupport.singletonList(new URL("file:///" + inputAsFQP)),  null, null);
+        final String propName = PLUGIN_NAME + InstallableComponentSupport.MIN_IDP_VERSION_INTERFIX +"1.0.0";
+        final String propValue = properties.getProperty(propName);
+        assertNotNull(propValue);
+        assertTrue("4.1.0".equals(propValue));
+}
+
+    @Test(dependsOnMethods = {"testLoadProperties"}) final void testParseInfo() {
+
+        //
+        // test old semantics
+        //
+        info = new TestInstallableComponent();
+        assertFalse(info.isInfoComplete());
+        assertTrue(info.getAvailableVersions().isEmpty());
+
+        
+        // add the version string
+        final String versionsAsString = "1.0.0 1.0.1 1.0.2 2.0.0 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2";
+        properties.setProperty("net.shibboleth.idp.plugin.authn.totp.versions", versionsAsString);
+        
+        info = new TestInstallableComponent();
+        assertTrue(info.isInfoComplete());
+
+        final List<String> ourVersions = CollectionSupport.listOf(versionsAsString.split(" "));
+        
+        for (final String version: ourVersions) {
+            assertNotNull(info.getAvailableVersions().get(new InstallableComponentVersion(version)));
+        }
+        assertNull(info.getAvailableVersions().get(new InstallableComponentVersion(1,2,3)));
+        
+    }
+    
+    @Test(dependsOnMethods = {"testParseInfo"}) final void testGetBestVersion() {
+        
+        InstallableComponentVersion best = InstallableComponentSupport.
+                getBestVersion(new InstallableComponentVersion(4, 2, 0), 
+                        new InstallableComponentVersion(1, 0, 0),
+                        info);
+        assertEquals(best, new InstallableComponentVersion(1,0,2));
+        best = InstallableComponentSupport.
+                getBestVersion(new InstallableComponentVersion(5, 5, 0), 
+                        new InstallableComponentVersion(1, 0, 0),
+                        info);
+        assertEquals(best, new InstallableComponentVersion(2,3,2));
+    }
+
+    
+    /**
+     * Based on the PluginInfo.
+     */
+    private class TestInstallableComponent extends InstallableComponentInfo {
+
+        /**  Constructor. */
+        public TestInstallableComponent() {
+            super(PLUGIN_NAME, properties);
+        }
+
+        @Override
+        protected @Nullable InstallableComponentVersion getMaxVersion(@Nonnull final Properties props,
+                @Nonnull final String version) {
+            final String maxVersionInfo = StringSupport.trimOrNull(
+                    props.getProperty(getComponentId()  + InstallableComponentSupport.MAX_IDP_VERSION_INTERFIX + version));
+            if (maxVersionInfo == null) {
+                return null;
+            }
+            return new InstallableComponentVersion(maxVersionInfo);
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        @Nullable
+        protected InstallableComponentVersion getMinVersion(@Nonnull final Properties props,
+                @Nonnull final String version) {
+            final String minVersionInfo = StringSupport.trimOrNull(
+                    props.getProperty(getComponentId() + InstallableComponentSupport.MIN_IDP_VERSION_INTERFIX + version));
+            if (minVersionInfo == null) {
+                return null;
+            }
+            return new InstallableComponentVersion(minVersionInfo);
+        }
+        
+    }
+}
diff --git a/shib-profile-api/src/test/resources/net/shibboleth/profile/installablecomponent/testfile.properties b/shib-profile-api/src/test/resources/net/shibboleth/profile/installablecomponent/testfile.properties
new file mode 100644
index 0000000..4052729
--- /dev/null
+++ b/shib-profile-api/src/test/resources/net/shibboleth/profile/installablecomponent/testfile.properties
@@ -0,0 +1,42 @@
+# Taken from a snapshot of the idp-mgmnt\plugin.properies file
+# net.shibboleth.idp.plugin.authn.totp.versions = 1.0.0 1.0.1 1.0.2 2.0.0 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2
+
+net.shibboleth.idp.plugin.authn.totp.downloadURL.%{version} = https://shibboleth.net/downloads/identity-provider/plugins/totp/%{version}
+net.shibboleth.idp.plugin.authn.totp.baseName.%{version} = idp-plugin-totp-dist-%{version}
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.1.0.0 = 4.2.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.1.0.0 = 4.1.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.1.0.0 = OutOfDate
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.1.0.1 = 4.2.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.1.0.1 = 4.2.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.1.0.1 = OutOfDate
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.1.0.2 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.1.0.2 = 4.2.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.1.0.2 = Current
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.0.0 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.0.0 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.0.0 = Withdrawn
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.1.0 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.1.0 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.1.0 = OutOfDate
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.2.0 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.2.0 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.2.0 = OutOfDate
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.3.0 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.3.0 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.3.0 = Withdrawn
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.3.1 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.3.1 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.3.1 = OutOfDate
+
+net.shibboleth.idp.plugin.authn.totp.idpVersionMax.2.3.2 = 6.0.0
+net.shibboleth.idp.plugin.authn.totp.idpVersionMin.2.3.2 = 5.0.0
+net.shibboleth.idp.plugin.authn.totp.supportLevel.2.3.2 = Current
+

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


More information about the commits mailing list