[java-plugin-shibd] branch main updated: Add more complex unit test and fix an agent wiring bug.

Scott Cantor cantor.2 at osu.edu
Mon Aug 25 18:37:19 UTC 2025


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

scantor pushed a commit to branch main
in repository java-plugin-shibd.

View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=829f4403dc4a583206b11a95b66ee5c58c086ff6

The following commit(s) were added to refs/heads/main by this push:
     new 829f440  Add more complex unit test and fix an agent wiring bug.
829f440 is described below

commit 829f4403dc4a583206b11a95b66ee5c58c086ff6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Aug 25 14:37:16 2025 -0400

    Add more complex unit test and fix an agent wiring bug.
---
 .../net/shibboleth/sp/conf/agents-system.xml       |  2 +-
 .../shibboleth/sp/service/AgentResolverTest.java   | 97 +++++++++++++++++++++-
 .../idp/module/conf/sp/agents-inheritance.xml      | 88 ++++++++++++++++++++
 3 files changed, 184 insertions(+), 3 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
index 9a35bfe..49e1ba7 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
@@ -75,7 +75,7 @@
         p:issuer="#{'%{sp.issuer:}'.trim()}"
         p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
         p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.sp.DefaultSecurityConfiguration}'.trim()}"
-        p:profileConfigurations-ref="shibboleth.DefaultProfileConfigurations" />
+        p:profileConfigurations-ref="shibboleth.sp.DefaultProfileConfigurations" />
 
     <!-- Parent bean for RelyingParty overrides based on activation by name(s). -->
     <bean id="RelyingPartyByName" abstract="true" parent="RelyingParty"
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/service/AgentResolverTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/service/AgentResolverTest.java
index 3b349aa..2e2b14e 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/service/AgentResolverTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/service/AgentResolverTest.java
@@ -77,7 +77,10 @@ public class AgentResolverTest extends AbstractTestNGSpringContextTests {
      */
     @AfterMethod
     public void tearDown() {
-        resolver.destroy();
+        if (resolver != null) {
+            resolver.destroy();
+            resolver = null;
+        }
     }
     
     /**
@@ -96,9 +99,99 @@ public class AgentResolverTest extends AbstractTestNGSpringContextTests {
         assert agent != null;
         validateDefaults(agent);
         Assert.assertEquals(agent.getSharedSecrets(), CollectionSupport.singletonList("foo"));
-        
         Assert.assertEquals(agent.getId(), "testsp.example.org");
     }
+
+    /**
+     * Test a more complex scenario involving inheritance and overrides.
+     * 
+     * @throws ComponentInitializationException
+     * @throws ResolverException
+     */
+    @Test public void testInheriting() throws ComponentInitializationException, ResolverException {
+        resolver = getResolver("/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml");
+        
+        // Resolve the agent.
+        final Agent agent = resolveAgent("inherit.example.org");
+        assert agent != null;
+        Assert.assertEquals(agent.getSharedSecrets(), CollectionSupport.singletonList("foo"));
+        Assert.assertEquals(agent.getId(), "inherit.example.org");
+
+        Assert.assertEquals(agent.getApplications().size(), 3);
+        Assert.assertEquals(agent.getAllowedAddressRanges(),
+                CollectionSupport.singletonList(IPRange.parseCIDRBlock("192.168.0.0/16")));
+
+        // Check the default application.
+        Application app = agent.getApplication(Agent.DEFAULT_APPLICATION_ID);
+        assert app != null;
+        Assert.assertEquals(app.getApplicationId(), Agent.DEFAULT_APPLICATION_ID);
+        Assert.assertEquals(app.getAuthenticatingAuthority(null), "https://example.org/idp");
+        Assert.assertEquals(app.getSessionInitiators(null), CollectionSupport.singletonList("SAML"));
+        Assert.assertEquals(app.getTokenConsumers(null), CollectionSupport.singletonList("SAML"));
+        
+        if (app instanceof BasicApplication basic) {
+            Assert.assertEquals(basic.getIssuer(null), "https://example.org/sp");
+            Assert.assertTrue(basic.getProfileConfigurations(null).isEmpty());
+        }
+        
+        // Check default vs. overridden RPC.
+        RelyingPartyConfiguration rpc = resolveRelyingParty(app, "https://idp.example.org");
+        Assert.assertSame(app, rpc);
+        
+        rpc = resolveRelyingParty(app, "https://idp.example.org/override");
+        assert rpc != null;
+        Assert.assertNotSame(app, rpc);
+        Assert.assertEquals(rpc.getIssuer(null), "https://example.org/override3");
+        
+        // Check the app overrides.
+        
+        // This one is inheriting.
+        app = agent.getApplication("override1");
+        assert app != null;
+        Assert.assertEquals(app.getId(), "override1");
+        Assert.assertEquals(app.getApplicationId(), "override1");
+        Assert.assertEquals(app.getAuthenticatingAuthority(null), "https://example.org/idp");
+        Assert.assertEquals(app.getSessionInitiators(null), CollectionSupport.singletonList("SAML"));
+        Assert.assertEquals(app.getTokenConsumers(null), CollectionSupport.singletonList("SAML"));
+        if (app instanceof BasicApplication basic) {
+            Assert.assertEquals(basic.getIssuer(null), "https://example.org/override1");
+            Assert.assertTrue(basic.getProfileConfigurations(null).isEmpty());
+        }
+        
+        // Check default vs. overridden RPC.
+        rpc = resolveRelyingParty(app, "https://idp.example.org");
+        Assert.assertSame(app, rpc);
+        
+        rpc = resolveRelyingParty(app, "https://idp.example.org/override");
+        assert rpc != null;
+        Assert.assertNotSame(app, rpc);
+        Assert.assertEquals(rpc.getIssuer(null), "https://example.org/override3");
+        
+        
+        // This one is non-inheriting, so the checked values revert to the wiring defaults.
+        app = agent.getApplication("override2");
+        assert app != null;
+        Assert.assertEquals(app.getId(), "override2");
+        Assert.assertEquals(app.getApplicationId(), "override2");
+        Assert.assertNull(app.getAuthenticatingAuthority(null));
+        Assert.assertTrue(app.getSessionInitiators(null).isEmpty());
+        Assert.assertTrue(app.getTokenConsumers(null).isEmpty());
+
+        if (app instanceof BasicApplication basic) {
+            Assert.assertEquals(basic.getIssuer(null), "https://example.org/override2");
+            Assert.assertTrue(basic.getProfileConfigurations(null).isEmpty());
+        }
+     
+        // Check default vs. overridden RPC.
+        // These are still inherited because by default the globally defined Unverified and Override beans get injected.
+        rpc = resolveRelyingParty(app, "https://idp.example.org");
+        Assert.assertSame(app, rpc);
+        
+        rpc = resolveRelyingParty(app, "https://idp.example.org/override");
+        assert rpc != null;
+        Assert.assertNotSame(app, rpc);
+        Assert.assertEquals(rpc.getIssuer(null), "https://example.org/override3");
+    }
     
     /**
      * Attempt to resolve an agent.
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml
new file mode 100644
index 0000000..1995ef1
--- /dev/null
+++ b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:c="http://www.springframework.org/schema/c"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+                           
+       default-init-method="initialize"
+       default-destroy-method="destroy">
+
+    <!--
+    This is a master file defining the Agents, Applications, and RelyingParty configurations to use.
+    You can add any number of additional imported files to organize your configuration.
+    
+    By default, the RelyingParty definitions below are used for all Applications unless overridden.
+    
+    This is an "empty" example in that it assumes neither SAML, OpenID, or any other protocols.
+    -->
+
+    <!-- ============ Agents and their Applications ============ -->
+
+    <bean p:id="inherit.example.org" parent="shibboleth.sp.Agent"
+            p:authenticationMethod="basic"
+            p:sharedSecrets="foo"
+            p:allowedAddressRanges="192.168.0.0/16"
+            p:issuer="https://example.org/sp"
+            p:authenticatingAuthority="https://example.org/idp"
+            p:sessionInitiators="#{{ 'SAML' }}"
+            p:tokenConsumers="#{{ 'SAML' }}">
+            
+        <property name="applications">
+            <list>
+                <bean p:id="override1" parent="shibboleth.sp.Application"
+                    p:issuer="https://example.org/override1" />
+        
+                <bean p:id="override2" parent="shibboleth.sp.Application.NoInheritance"
+                    p:issuer="https://example.org/override2" />
+            </list>
+        </property>
+    </bean>
+    
+
+    <!-- ============ Profile defaults ============ -->
+    
+    <!-- Used for all applications by default to provide a baseline for profile settings. -->
+
+    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
+        <!-- Your profiles here. -->
+    </util:list>
+
+
+    <!-- ============ RelyingParty defaults ============ -->
+    
+    <!--
+    These beans are wired into *all* applications across all agents by default. You can create
+    customized alternatives in whatever combination you require to plug into specific application
+    beans.
+    -->
+
+    <!--
+    Unverified RP configuration, defaults to no support for any profiles. Add <ref> elements to the list
+    to enable specific default profile settings (as below), or create new beans inline to override defaults.
+    
+    "Unverified" typically means the SP has no metadata, or equivalent way of assuring the identity and
+    legitimacy of an IdP system. To run an "open" SP, you can enable profiles here.
+    -->
+    <bean id="shibboleth.sp.UnverifiedRelyingParty" parent="RelyingParty">
+        <property name="profileConfigurations">
+            <list>
+            <!-- Your profiles here. -->
+            </list>
+        </property>
+    </bean>
+
+    <!-- Container for any overrides you want to add. -->
+
+    <util:list id="shibboleth.sp.RelyingPartyOverrides">
+    
+        <bean parent="RelyingPartyByName" c:relyingPartyIds="https://idp.example.org/override"
+            p:issuer="https://example.org/override3"/>
+    
+    </util:list>
+
+</beans>

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


More information about the commits mailing list