[java-shib-attribute] branch main updated: Adjust tests to use https and embedded Jetty.
Codeberg
noreply at shibboleth.net
Mon Sep 14 18:50:34 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-attribute.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-attribute/commit/68c10248a44a1080caa243d6acaae808b2f208ef
The following commit(s) were added to refs/heads/main by this push:
new 68c10248a Adjust tests to use https and embedded Jetty.
68c10248a is described below
commit 68c10248a44a1080caa243d6acaae808b2f208ef
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Sep 14 14:50:25 2026 -0400
Adjust tests to use https and embedded Jetty.
---
.../dc/http/impl/HTTPDataConnectorTest.java | 43 +++++++++++++++++-----
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/HTTPDataConnectorTest.java b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/HTTPDataConnectorTest.java
index 2e930fdc0..69a55bbd5 100644
--- a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/HTTPDataConnectorTest.java
+++ b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/HTTPDataConnectorTest.java
@@ -57,6 +57,7 @@ import net.shibboleth.idp.attribute.resolver.testing.TestSources;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.httpclient.HttpClientBuilder;
+import net.shibboleth.shared.primitive.NonnullSupplier;
import net.shibboleth.shared.resource.Resource;
import net.shibboleth.shared.spring.resource.ResourceHelper;
import net.shibboleth.shared.testing.EmbeddedJetty;
@@ -78,12 +79,23 @@ public class HTTPDataConnectorTest {
private EmbeddedJetty jetty;
private HTTPDataConnector connector;
+ private int httpStatus;
@BeforeClass
public void startJetty() throws IOException {
jetty = new EmbeddedJetty();
- final EmbeddedJetty.ResourceHandler handler = new EmbeddedJetty.ResourceHandler(200,
- ResourceHelper.of(new ClassPathResource("net/shibboleth/idp/attribute/resolver/impl/dc/http/test.json")));
+ final EmbeddedJetty.ResourceHandler handler = new EmbeddedJetty.ResourceHandler(
+ new NonnullSupplier<Integer>() {
+ public Integer get() {
+ return httpStatus;
+ }
+ },
+ new NonnullSupplier<Resource>() {
+ public Resource get() {
+ return ResourceHelper.of(new ClassPathResource("net/shibboleth/idp/attribute/resolver/impl/dc/http/test.json"));
+ }
+
+ });
handler.setContentType("application/json");
jetty.startServer(handler);
}
@@ -96,27 +108,31 @@ public class HTTPDataConnectorTest {
}
}
- @BeforeMethod public void setUp() throws Exception {
+ @BeforeMethod
+ public void setUp() throws Exception {
+ httpStatus = HttpStatus.SC_OK;
+
connector = new HTTPDataConnector();
connector.setId(TEST_CONNECTOR_NAME);
final HttpClientBuilder builder = new HttpClientBuilder();
- builder.setTLSSocketFactory(SecurityEnhancedHttpClientSupport.buildTLSSocketFactory(false, false));
+ builder.setTLSSocketFactory(SecurityEnhancedHttpClientSupport.buildTLSSocketFactory(true, false));
connector.setHttpClient(builder.buildClient());
}
- @Test public void test() throws ComponentInitializationException, ResolutionException, ScriptException, IOException {
+ @Test
+ public void test() throws Exception {
final HttpClientSecurityParameters params = new HttpClientSecurityParameters();
- params.setTLSProtocols(CollectionSupport.singleton("TLSv1"));
+ params.setTLSTrustEngine(buildExplicitKeyTrustEngine(EmbeddedJetty.getServerCertficateResource()));
// TODO: this will get the header included but isn't actually being tested/enforced atm.
params.setPreemptiveBasicAuthMap(
- CollectionSupport.singletonMap(new HttpHost("http", "localhost", 8080),
+ CollectionSupport.singletonMap(new HttpHost("https", "localhost", 8443),
new UsernamePasswordCredentials("jdoe", "foo".toCharArray())));
connector.setHttpClientSecurityParameters(params);
final TemplatedURLBuilder builder = new TemplatedURLBuilder();
- builder.setTemplateText(TEST_HTTP_URL);
+ builder.setTemplateText(TEST_HTTPS_URL);
builder.setVelocityEngine(VelocityEngine.newVelocityEngine());
builder.setHttpClientSecurityParameters(params);
builder.setHeaders(CollectionSupport.singletonMap("Accept", "test/html"));
@@ -237,9 +253,16 @@ public class HTTPDataConnectorTest {
connector.resolve(context);
}
- @Test public void testMissingOk() throws ComponentInitializationException, ResolutionException, ScriptException {
+ @Test public void testMissingOk() throws Exception {
+ httpStatus = HttpStatus.SC_NOT_FOUND;
+
+ final HttpClientSecurityParameters params = new HttpClientSecurityParameters();
+ params.setTLSTrustEngine(buildExplicitKeyTrustEngine(EmbeddedJetty.getServerCertficateResource()));
+
+ connector.setHttpClientSecurityParameters(params);
+
final TemplatedURLBuilder builder = new TemplatedURLBuilder();
- builder.setTemplateText("https://build.shibboleth.net/test.json");
+ builder.setTemplateText(TEST_HTTPS_URL);
builder.setVelocityEngine(VelocityEngine.newVelocityEngine());
builder.initialize();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list