[java-shib-metadata] branch main updated: Remediate tests not in use.
Codeberg
noreply at shibboleth.net
Mon Jul 13 20:47:48 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/ccac40189d7b36713005381b75860ee7c44e3d78
The following commit(s) were added to refs/heads/main by this push:
new ccac4018 Remediate tests not in use.
ccac4018 is described below
commit ccac40189d7b36713005381b75860ee7c44e3d78
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Jul 13 16:47:37 2026 -0400
Remediate tests not in use.
---
.../spring/metadata/MetadataFailFastTest.java | 71 ++++++++++++++++++----
1 file changed, 58 insertions(+), 13 deletions(-)
diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/MetadataFailFastTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/MetadataFailFastTest.java
index f4f7522b..634a494c 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/MetadataFailFastTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/MetadataFailFastTest.java
@@ -17,20 +17,29 @@ package net.shibboleth.spring.metadata;
import static org.testng.Assert.*;
import java.io.IOException;
+import java.net.SocketException;
+import java.net.UnknownHostException;
import java.util.List;
import javax.annotation.Nonnull;
import org.opensaml.saml.metadata.resolver.MetadataResolver;
+import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.env.MockPropertySource;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.NonnullSupplier;
+import net.shibboleth.shared.resource.Resource;
import net.shibboleth.shared.service.ReloadableService;
import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
-import net.shibboleth.shared.testing.RepositorySupport;
+import net.shibboleth.shared.spring.resource.ResourceHelper;
+import net.shibboleth.shared.testing.EmbeddedJetty;
import net.shibboleth.spring.testing.AbstractFailFastTest;
/**
@@ -39,18 +48,47 @@ import net.shibboleth.spring.testing.AbstractFailFastTest;
@Ignore
@SuppressWarnings({"unchecked", "javadoc"})
public class MetadataFailFastTest extends AbstractFailFastTest {
+
private static int uniquifier;
- /** return an HTTP URL for the file of this name
- * @param filePart
- * @return the URL (as a string)
- */
- @Nonnull protected String makeURLPath(final String filePart) {
- return RepositorySupport.buildHTTPResourceURL("java-shib-metadata",
- "shib-metadata-spring/src/test/resources" + getPath() + filePart,
- false);
+ private EmbeddedJetty jetty;
+ private int jettyStatus;
+ private Resource jettyResource;
+ private Resource goodResource;
+ private Resource badResource;
+
+ @BeforeClass
+ public void startJetty() throws UnknownHostException, SocketException {
+ goodResource = ResourceHelper.of(new ClassPathResource(getPath() + "metadataFileGood.xml"));
+ badResource = ResourceHelper.of(new ClassPathResource(getPath() + "metadataFileBad.xml"));
+
+ jetty = new EmbeddedJetty();
+ jetty.startServer(new EmbeddedJetty.ResourceHandler(
+ new NonnullSupplier<Integer>() {
+ @Nonnull public Integer get() {
+ return jettyStatus;
+ }
+ },
+ new NonnullSupplier<Resource>() {
+ @Nonnull public Resource get() {
+ return jettyResource;
+ }
+ }));
+ }
+
+ @AfterClass
+ public void stopJetty() {
+ if (jetty != null) {
+ jetty.stopServer();
+ jetty = null;
+ }
}
-
+
+ @BeforeMethod
+ public void initJettyStatus() {
+ jettyStatus = 200;
+ }
+
@Test public void workingInline() throws IOException {
final Object bean = getBean(propertySource("ServiceConfiguration", makePath("inLineMetadataGood.xml")), "metadataBeansDefaultFF.xml");
@@ -152,10 +190,12 @@ public class MetadataFailFastTest extends AbstractFailFastTest {
}
@Test public void workingHttp() throws IOException {
+ jettyResource = goodResource;
+
final List<MockProperty> prop = CollectionSupport.listOf(
new MockProperty("ServiceConfiguration", makePath("httpMetadata.xml")),
new MockProperty("Backing", makeTempPath("workingHttpTmp" + uniquifier++ + ".xml")),
- new MockProperty("metadataURL", makeURLPath("metadataFileGood.xml")));
+ new MockProperty("metadataURL", "http://localhost:8080/good.xml"));
final Object bean = getBean(propertySource(prop), "metadataBeansDefaultFF.xml");
final ReloadableService<MetadataResolver > service = (ReloadableService<MetadataResolver>) bean;
@@ -168,10 +208,12 @@ public class MetadataFailFastTest extends AbstractFailFastTest {
}
private void badHttp(final Boolean failFast) throws IOException {
+ jettyResource = badResource;
+
final List<MockProperty> prop = CollectionSupport.listOf(
new MockProperty("ServiceConfiguration", makePath("httpMetadata.xml")),
new MockProperty("Backing", makeTempPath("badHttpTmp" + uniquifier++ + ".xml")),
- new MockProperty("metadataURL", makeURLPath("metadataFileBad.xml")));
+ new MockProperty("metadataURL", "http://localhost:8080/bad.xml"));
nonWorkingMetadata(failFast, propertySource(prop));
}
@@ -188,10 +230,13 @@ public class MetadataFailFastTest extends AbstractFailFastTest {
}
private void nonExistingHttp(final Boolean failFast) throws IOException {
+ jettyResource = goodResource;
+ jettyStatus = 404;
+
final List<MockProperty> prop = CollectionSupport.listOf(
new MockProperty("ServiceConfiguration", makePath("httpMetadata.xml")),
new MockProperty("Backing", makeTempPath("badHttpTmp" + uniquifier++ + ".xml")),
- new MockProperty("metadataURL", makeURLPath("ItsNotThere.xml")));
+ new MockProperty("metadataURL", "http://localhost:8080/missing.xml"));
nonWorkingMetadata(failFast, propertySource(prop));
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list