[java-plugin-shibd] branch main updated: Adjust test initialization to allow further nesting of test classes.
Codeberg
noreply at shibboleth.net
Fri Nov 21 01:05:28 UTC 2025
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/879db55d352ab02eeb39fa1f6c08f36a83d1f2ce
The following commit(s) were added to refs/heads/main by this push:
new 879db55 Adjust test initialization to allow further nesting of test classes.
879db55 is described below
commit 879db55d352ab02eeb39fa1f6c08f36a83d1f2ce
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Nov 20 20:05:12 2025 -0500
Adjust test initialization to allow further nesting of test classes.
---
.../idp/flows/sp/storage/storage-beans.xml | 2 +-
.../shibboleth/sp/flows/AbstractSPFlowTest.java | 10 +++-
...SPEnvironmentApplicationContextInitializer.java | 62 ++++++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/storage/storage-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/storage/storage-beans.xml
index df35b1c..507a744 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/storage/storage-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/storage/storage-beans.xml
@@ -13,6 +13,6 @@
<bean id="DoStorageOperation"
class="net.shibboleth.sp.profile.impl.DoStorageOperation" scope="prototype"
p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
- p:storageService-ref="#{'%{sp.storageService:shibboleth.StorageService}'.trim()}" />
+ p:storageService-ref="#{'%{sp.storageService}'.trim()}" />
</beans>
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
index 63a3651..214d5d5 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
@@ -35,6 +35,8 @@ import org.springframework.webflow.test.MockExternalContext;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
+import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
+import net.shibboleth.idp.test.PreferFileSystemApplicationContextInitializer;
import net.shibboleth.idp.test.flows.AbstractFlowTest;
import net.shibboleth.shared.servlet.impl.HttpServletRequestResponseContext;
import net.shibboleth.shared.xml.ParserPool;
@@ -47,7 +49,13 @@ import net.shibboleth.sp.profile.impl.ResolveApplication;
@ContextConfiguration(
locations = {
"classpath*:/META-INF/net.shibboleth.idp/postconfig.xml"
- }
+ },
+ initializers = {
+ TestSPEnvironmentApplicationContextInitializer.class,
+ PreferFileSystemApplicationContextInitializer.class,
+ IdPPropertiesApplicationContextInitializer.class
+ },
+ inheritInitializers=false
)
public abstract class AbstractSPFlowTest extends AbstractFlowTest {
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/TestSPEnvironmentApplicationContextInitializer.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/TestSPEnvironmentApplicationContextInitializer.java
new file mode 100644
index 0000000..2b09a6a
--- /dev/null
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/TestSPEnvironmentApplicationContextInitializer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.sp.flows;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.mock.env.MockPropertySource;
+
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * An {@link ApplicationContextInitializer} which prepends properties.
+ *
+ * <p>This needs to include the original IdP-test-layer properties and has to be
+ * set to {@link Ordered#LOWEST_PRECEDENCE} or things blow up.</p>
+ */
+ at Order(Ordered.LOWEST_PRECEDENCE)
+public class TestSPEnvironmentApplicationContextInitializer
+ implements ApplicationContextInitializer<ConfigurableApplicationContext> {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(TestSPEnvironmentApplicationContextInitializer.class);
+
+ /**
+ * Add properties for tests.
+ *
+ * @param mock property source
+ */
+ protected void addProperties(@Nonnull final MockPropertySource mock) {
+ mock.setProperty("idp.home", "classpath:/net/shibboleth/idp/module");
+ mock.setProperty("idp.webflows", "classpath*:/flows");
+ mock.setProperty("sp.storageService", "shibboleth.StorageService");
+ mock.setProperty("idp.additionalProperties",
+ "/conf/ldap.properties, /conf/saml-nameid.properties, /conf/services.properties, /conf/admin/admin.properties, /conf/authn/authn.properties, /conf/c14n/subject-c14n.properties, /credentials/secrets.properties, /conf/sp/sp.properties");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void initialize(@Nonnull final ConfigurableApplicationContext applicationContext) {
+ final MockPropertySource mock = new MockPropertySource();
+ addProperties(mock);
+ applicationContext.getEnvironment().getPropertySources().addFirst(mock);
+ log.info("Prepending properties '{}'", mock.getSource());
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list