[java-metadata-aggregator] branch main updated: MDA-277 - Implement migration assistance with bean post-processor

Ian Young ian at iay.org.uk
Thu Feb 2 07:08:30 UTC 2023


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=1033bfe06df620d13caaa39072f810b362269a42

The following commit(s) were added to refs/heads/main by this push:
     new 1033bfe  MDA-277 - Implement migration assistance with bean post-processor
1033bfe is described below

commit 1033bfe06df620d13caaa39072f810b362269a42
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Feb 2 07:08:28 2023 +0000

    MDA-277 - Implement migration assistance with bean post-processor
    
    https://shibboleth.atlassian.net/browse/MDA-277
---
 mda-framework/pom.xml                              | 10 +++++
 .../resources/net/shibboleth/metadata/beans.xml    | 27 +++++++++++++
 .../net/shibboleth/metadata/BeansFileTest.java     | 47 ++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/mda-framework/pom.xml b/mda-framework/pom.xml
index 776f602..0bb81a4 100644
--- a/mda-framework/pom.xml
+++ b/mda-framework/pom.xml
@@ -81,6 +81,16 @@
             <artifactId>shib-spring</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>net.shibboleth</groupId>
+            <artifactId>shib-networking-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.shibboleth</groupId>
+            <artifactId>shib-security-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.jruby</groupId>
             <artifactId>jruby</artifactId>
diff --git a/mda-framework/src/main/resources/net/shibboleth/metadata/beans.xml b/mda-framework/src/main/resources/net/shibboleth/metadata/beans.xml
index d0bfb14..eefaa9a 100644
--- a/mda-framework/src/main/resources/net/shibboleth/metadata/beans.xml
+++ b/mda-framework/src/main/resources/net/shibboleth/metadata/beans.xml
@@ -331,4 +331,31 @@
     <bean id="mda.X509RSAOpenSSLBlacklistValidator" abstract="true" parent="mda.validator_parent"
         class="net.shibboleth.metadata.validate.x509.X509RSAOpenSSLBlacklistValidator"/>
 
+	<!--
+		***************************************************
+		***                                             ***
+		***   M I G R A T I O N   A S S I S T A N C E   ***
+		***                                             ***
+		***************************************************
+	-->
+
+	<bean id="mda.RelocatedBeanFactoryPostProcessor" abstract="true"
+		class="net.shibboleth.shared.spring.config.RelocatedBeanFactoryPostProcessor"/>
+
+	<bean id="mda.MigrationAssistanceBean" parent="mda.RelocatedBeanFactoryPostProcessor"
+		lazy-init="false" p:classes-ref="mda.MigrationClassMap" p:beans-ref="mda.MigrationBeanMap"/>
+
+	<util:map id="mda.MigrationClassMap">
+		<!-- MDA changes from 0.9 to 0.10 -->
+
+		<!-- dependency changes from 0.9 to 0.10 -->
+		<entry key="net.shibboleth.ext.spring.resource.HTTPResource"
+			 value="net.shibboleth.shared.spring.httpclient.resource.HTTPResource"/>
+
+	</util:map>
+
+	<util:map id="mda.MigrationBeanMap">
+
+	</util:map>
+
 </beans>
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/BeansFileTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/BeansFileTest.java
index 912e77b..2e961e3 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/BeansFileTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/BeansFileTest.java
@@ -1,6 +1,9 @@
 
 package net.shibboleth.metadata;
 
+import java.util.Map;
+import java.util.Set;
+
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.support.GenericApplicationContext;
@@ -12,6 +15,14 @@ public class BeansFileTest {
 
     @Test
     public void testBeans() throws Exception {
+
+        // Set of beans which don't follow some of the normal rules
+        final Set<String> specialBeans = Set.of(
+                "mda.MigrationAssistanceBean",
+                "mda.MigrationClassMap",
+                "mda.MigrationBeanMap"
+                );
+
         // Create an application context, which also acts as a bean definition registry
         final GenericApplicationContext ctx = new GenericApplicationContext();
 
@@ -26,6 +37,12 @@ public class BeansFileTest {
             // All bean definitions should start with "mda."
             Assert.assertTrue(defName.startsWith("mda."), "does not start with correct prefix: " + defName);
 
+            // Skip special beans on the first pass, process them only after the context has
+            // been refreshed.
+            if (specialBeans.contains(defName)) {
+                continue;
+            }
+
             // All bean definitions should be abstract
             Assert.assertTrue(def.isAbstract(), "not abstract: " + defName);
 
@@ -55,6 +72,36 @@ public class BeansFileTest {
         // Refresh the context to process the bean definitions
         ctx.refresh();
 
+        // Process the special beans
+        for (final String defName : defNames) {
+            switch (defName) {
+                /*
+                 * Check that the mapped classes in the migration class map
+                 * resolve to a class that actually exists.
+                 */
+                case "mda.MigrationClassMap" -> {
+                    final Map<String, String> map = ctx.getBean(defName, Map.class);
+                    for (String toClass : map.values()) {
+                        // check that the mapped class name can be loaded
+                        Class.forName(toClass);
+                    }
+                }
+
+                /*
+                 * Check that the mapped beans in the migration bean map
+                 * have definitions.
+                 */
+                case "mda.MigrationBeanMap" -> {
+                    final Map<String, String> map = ctx.getBean(defName, Map.class);
+                    for (String toBean : map.values()) {
+                        // check that the mapped bean name is defined
+                        ctx.getBeanDefinition(toBean);
+                    }
+                }
+                    
+            }
+
+        }
     }
 
 }

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


More information about the commits mailing list