[java-opensaml] branch main updated: Copy Jetty keystore into temp file for tests.
Codeberg
noreply at shibboleth.net
Mon Jul 13 18:31:39 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-opensaml.
View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/7702401198a0c81ee6e9ef0a48f7d7965937f262
The following commit(s) were added to refs/heads/main by this push:
new 770240119 Copy Jetty keystore into temp file for tests.
770240119 is described below
commit 7702401198a0c81ee6e9ef0a48f7d7965937f262
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Jul 13 14:31:29 2026 -0400
Copy Jetty keystore into temp file for tests.
---
.../impl/FileBackedHTTPMetadataResolverTest.java | 17 +++++++++-----
...ctionDrivenDynamicHTTPMetadataResolverTest.java | 24 +++++++++++++++-----
.../resolver/impl/HTTPMetadataResolverTest.java | 26 ++++++++++++++++------
3 files changed, 50 insertions(+), 17 deletions(-)
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
index 55fb2bc47..48ba6cc3c 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
@@ -17,8 +17,6 @@ package org.opensaml.saml.metadata.resolver.impl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.SocketException;
-import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
@@ -64,6 +62,7 @@ public class FileBackedHTTPMetadataResolverTest extends XMLObjectBaseTestCase {
private EmbeddedJetty jetty;
private int jettyStatus;
+ private String keystorePath;
private HttpClientBuilder httpClientBuilder;
@@ -80,13 +79,19 @@ public class FileBackedHTTPMetadataResolverTest extends XMLObjectBaseTestCase {
private CriteriaSet criteriaSet;
@BeforeClass
- public void startJetty() throws UnknownHostException, SocketException {
+ public void startJetty() throws IOException {
relativeMDResource = ResourceHelper.of(new ClassPathResource("org/opensaml/saml/metadata/resolver/impl/08ced64cddc9f1578598b2cf71ae747b11d11472.xml"));
relativeMDResourceExpired = ResourceHelper.of(new ClassPathResource("org/opensaml/saml/metadata/resolver/impl/08ced64cddc9f1578598b2cf71ae747b11d11473-expired.xml"));
relativeMDResourceBad = ResourceHelper.of(new ClassPathResource("org/opensaml/saml/metadata/resolver/impl/08ced64cddc9f1578598b2cf71ae747b11d11473-bad.xml"));
metadataURLHttps = "https://localhost:8443/metadata.xml";
metadataURLHttp = "http://localhost:8080/metadata.xml";
+ // Copy Jetty keystore from jar classpath to file system for Java system property testing.
+ keystorePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "localhost-keystore.p12";
+ try (final FileOutputStream keystoreStream = new FileOutputStream(keystorePath)) {
+ Resources.copy(EmbeddedJetty.getServerKeystoreResource().getURL(), keystoreStream);
+ }
+
jetty = new EmbeddedJetty();
jetty.startServer(new EmbeddedJetty.ResourceHandler(
new NonnullSupplier<Integer>() {
@@ -99,11 +104,13 @@ public class FileBackedHTTPMetadataResolverTest extends XMLObjectBaseTestCase {
}
@AfterClass
- public void stopJetty() {
+ public void stopJetty() throws IOException {
if (jetty != null) {
jetty.stopServer();
jetty = null;
}
+
+ Files.delete(Path.of(keystorePath));
}
@BeforeMethod
@@ -551,7 +558,7 @@ public class FileBackedHTTPMetadataResolverTest extends XMLObjectBaseTestCase {
@Test
public void testHTTPSNoTrustEngine() throws Exception {
try {
- System.setProperty("javax.net.ssl.trustStore", EmbeddedJetty.getServerKeystoreResource().getFile().getPath());
+ System.setProperty("javax.net.ssl.trustStore", keystorePath);
System.setProperty("javax.net.ssl.trustStorePassword", EmbeddedJetty.getServerKeystorePassword());
httpClientBuilder.setTLSSocketFactory(HTTPMetadataResolverTest.buildSocketFactory(false));
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
index e7243a792..88293fa33 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
@@ -14,8 +14,11 @@
package org.opensaml.saml.metadata.resolver.impl;
-import java.net.SocketException;
-import java.net.UnknownHostException;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
@@ -41,6 +44,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
+import com.google.common.io.Resources;
import net.shibboleth.shared.codec.StringDigester;
import net.shibboleth.shared.codec.StringDigester.OutputFormat;
@@ -58,6 +62,7 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
private EmbeddedJetty jetty;
private int jettyStatus;
+ private String keystorePath;
private Resource relativeMDResource;
@@ -66,9 +71,16 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
private HttpClientBuilder httpClientBuilder;
@BeforeClass
- public void startJetty() throws UnknownHostException, SocketException {
+ public void startJetty() throws FileNotFoundException, IOException {
+
relativeMDResource = ResourceHelper.of(new ClassPathResource("org/opensaml/saml/metadata/resolver/impl/localhost-sp.xml"));
+ // Copy Jetty keystore from jar classpath to file system for Java system property testing.
+ keystorePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "localhost-keystore.p12";
+ try (final FileOutputStream keystoreStream = new FileOutputStream(keystorePath)) {
+ Resources.copy(EmbeddedJetty.getServerKeystoreResource().getURL(), keystoreStream);
+ }
+
jetty = new EmbeddedJetty();
final var handler = new EmbeddedJetty.ResourceHandler(
new NonnullSupplier<Integer>() {
@@ -83,11 +95,13 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
}
@AfterClass
- public void stopJetty() {
+ public void stopJetty() throws IOException {
if (jetty != null) {
jetty.stopServer();
jetty = null;
}
+
+ Files.delete(Path.of(keystorePath));
}
@BeforeMethod
@@ -373,7 +387,7 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
@Test
public void testHTTPSNoTrustEngine() throws Exception {
try {
- System.setProperty("javax.net.ssl.trustStore", EmbeddedJetty.getServerKeystoreResource().getFile().getPath());
+ System.setProperty("javax.net.ssl.trustStore", keystorePath);
System.setProperty("javax.net.ssl.trustStorePassword", EmbeddedJetty.getServerKeystorePassword());
final String template = "https://localhost:8443/entities/${entityID}.xml";
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolverTest.java
index bd473f718..16f437097 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolverTest.java
@@ -14,11 +14,13 @@
package org.opensaml.saml.metadata.resolver.impl;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.SocketException;
import java.net.URISyntaxException;
-import java.net.UnknownHostException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Set;
@@ -52,6 +54,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.common.io.ByteStreams;
+import com.google.common.io.Resources;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
@@ -70,6 +73,7 @@ import net.shibboleth.shared.testing.EmbeddedJetty;
public class HTTPMetadataResolverTest extends XMLObjectBaseTestCase {
private EmbeddedJetty jetty;
+ private String keystorePath;
private HttpClientBuilder httpClientBuilder;
@@ -83,20 +87,28 @@ public class HTTPMetadataResolverTest extends XMLObjectBaseTestCase {
static final String DATA_PATH = "/org/opensaml/saml/metadata/resolver/impl/";
@BeforeClass
- protected void setUpClass() throws UnknownHostException, SocketException {
+ protected void setUpClass() throws FileNotFoundException, IOException {
+ metadataURLHttps = "https://localhost:8443/08ced64cddc9f1578598b2cf71ae747b11d11472.xml";
+ metadataURLHttp = "http://localhost:8080/08ced64cddc9f1578598b2cf71ae747b11d11472.xml";
+
+ // Copy Jetty keystore from jar classpath to file system for Java system property testing.
+ keystorePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "localhost-keystore.p12";
+ try (final FileOutputStream keystoreStream = new FileOutputStream(keystorePath)) {
+ Resources.copy(EmbeddedJetty.getServerKeystoreResource().getURL(), keystoreStream);
+ }
+
jetty = new EmbeddedJetty();
jetty.startServer(new EmbeddedJetty.ResourceHandler(200,
ResourceHelper.of(new ClassPathResource("org/opensaml/saml/metadata/resolver/impl/08ced64cddc9f1578598b2cf71ae747b11d11472.xml"))));
- metadataURLHttps = "https://localhost:8443/08ced64cddc9f1578598b2cf71ae747b11d11472.xml";
- metadataURLHttp = "http://localhost:8080/08ced64cddc9f1578598b2cf71ae747b11d11472.xml";
}
@AfterClass
- public void stopJetty() {
+ public void stopJetty() throws IOException {
if (jetty != null) {
jetty.stopServer();
jetty = null;
}
+ Files.delete(Path.of(keystorePath));
}
@BeforeMethod
@@ -255,7 +267,7 @@ public class HTTPMetadataResolverTest extends XMLObjectBaseTestCase {
@Test
public void testHTTPSNoTrustEngine() throws Exception {
try {
- System.setProperty("javax.net.ssl.trustStore", EmbeddedJetty.getServerKeystoreResource().getFile().getPath());
+ System.setProperty("javax.net.ssl.trustStore", keystorePath);
System.setProperty("javax.net.ssl.trustStorePassword", EmbeddedJetty.getServerKeystorePassword());
httpClientBuilder.setTLSSocketFactory(buildSocketFactory(false));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list