This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch camel-quarkus-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git


The following commit(s) were added to refs/heads/camel-quarkus-main by this 
push:
     new 205026b8 http-pqc-j21: Replace httpclient5 test dependency with 
RestAssured
205026b8 is described below

commit 205026b82ff262c8f74173456788935c1602ad07
Author: James Netherton <[email protected]>
AuthorDate: Fri Aug 7 15:01:10 2026 +0100

    http-pqc-j21: Replace httpclient5 test dependency with RestAssured
    
    * chore: http-pqc-j21: replace httpclient5 test dependency with RestAssured
    
    The httpclient5 dependency was only used in tests to select a specific
    JSSE provider and set TLS named groups. Both can be achieved with
    RestAssured's SSLConfig.sslSocketFactory() backed by a provider-specific
    SSLContext, since the named groups are already controlled by the
    jdk.tls.namedGroups system property set by the test profiles.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    * chore: http-pqc-j21: use strict hostname verifier and constrain to TLS 1.3
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 http-pqc-j21/README.adoc                           |  2 +-
 http-pqc-j21/pom.xml                               |  6 --
 .../java/org/acme/http/pqc/AbstractPqcTest.java    | 81 ++++++++--------------
 .../test/java/org/acme/http/pqc/PqcOnlyTest.java   |  2 +-
 .../org/acme/http/pqc/PqcWithFallbackTest.java     |  2 +-
 5 files changed, 30 insertions(+), 63 deletions(-)

diff --git a/http-pqc-j21/README.adoc b/http-pqc-j21/README.adoc
index 4b3c629c..d6da4561 100644
--- a/http-pqc-j21/README.adoc
+++ b/http-pqc-j21/README.adoc
@@ -121,7 +121,7 @@ Configure `application.properties` to disable classical 
fallback:
 jdk.tls.namedGroups=X25519MLKEM768
 ----
 
-To actually test X25519MLKEM768 hybrid key exchange, use a PQC-capable client. 
The test suite demonstrates this using Apache HttpClient 5 with BouncyCastle 
JSSE:
+To actually test X25519MLKEM768 hybrid key exchange, use a PQC-capable client. 
The test suite demonstrates this using RestAssured with a BouncyCastle 
JSSE-backed SSLContext:
 
 [source,shell]
 ----
diff --git a/http-pqc-j21/pom.xml b/http-pqc-j21/pom.xml
index 6711001d..04c88904 100644
--- a/http-pqc-j21/pom.xml
+++ b/http-pqc-j21/pom.xml
@@ -115,12 +115,6 @@
             <artifactId>awaitility</artifactId>
             <scope>test</scope>
         </dependency>
-        <!-- Apache HttpClient 5 for explicit JSSE provider control in tests 
-->
-        <dependency>
-            <groupId>org.apache.httpcomponents.client5</groupId>
-            <artifactId>httpclient5</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java 
b/http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java
index 3ff13237..073274e1 100644
--- a/http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java
+++ b/http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java
@@ -19,23 +19,15 @@ package org.acme.http.pqc;
 import java.io.FileInputStream;
 import java.security.KeyStore;
 import java.security.Security;
-import java.util.Arrays;
 
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLParameters;
 import javax.net.ssl.TrustManagerFactory;
 
 import io.restassured.RestAssured;
 import io.restassured.config.RestAssuredConfig;
 import io.restassured.config.SSLConfig;
-import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
-import 
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
-import org.apache.hc.client5.http.io.HttpClientConnectionManager;
-import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
-import org.apache.hc.core5.http.HttpResponse;
+import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
 import org.jboss.logging.Logger;
@@ -46,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 /**
- * Abstract base class for Apache HttpClient PQC tests with explicit provider 
selection.
+ * Abstract base class for PQC tests with explicit JSSE provider selection.
  * Tests both BCJSSE (PQC-capable) and SunJSSE (classical only) providers.
  *
  * Certificates are generated before tests via CertificateTestResource.
@@ -84,54 +76,35 @@ abstract class AbstractPqcTest {
     }
 
     void testHttpClientConnection(String securityProvider, boolean 
expectFailure) throws Exception {
-        boolean failedAsExpected = false;
-
         try {
             SSLContext sslContext = createSslContext(securityProvider);
-
-            // Create custom SSLConnectionSocketFactory that explicitly sets 
named groups
-            SSLConnectionSocketFactory sslSocketFactory = new 
SSLConnectionSocketFactory(sslContext) {
-                @Override
-                protected void prepareSocket(javax.net.ssl.SSLSocket socket) 
throws java.io.IOException {
-                    super.prepareSocket(socket);
-                    // Explicitly set named groups on the socket's SSL 
parameters
-                    String configuredGroups = 
System.getProperty("jdk.tls.namedGroups", "X25519MLKEM768");
-                    try {
-                        SSLParameters sslParams = socket.getSSLParameters();
-                        String[] namedGroupsArray = 
configuredGroups.split(",");
-                        for (int i = 0; i < namedGroupsArray.length; i++) {
-                            namedGroupsArray[i] = namedGroupsArray[i].trim();
-                        }
-                        sslParams.setNamedGroups(namedGroupsArray);
-                        sslParams.setProtocols(new String[] { "TLSv1.3" });
-                        socket.setSSLParameters(sslParams);
-                        LOG.info("Set named groups on socket: " + 
Arrays.toString(namedGroupsArray));
-                    } catch (Exception e) {
-                        LOG.warn("Could not set named groups on socket: " + 
e.getMessage());
-                    }
-                }
-            };
-
-            HttpClientConnectionManager connectionManager = 
PoolingHttpClientConnectionManagerBuilder.create()
-                    .setSSLSocketFactory(sslSocketFactory)
-                    .build();
-
-            try (CloseableHttpClient httpClient = HttpClients.custom()
-                    .setConnectionManager(connectionManager)
-                    .build()) {
-
-                HttpGet request = new HttpGet("https://localhost:"; + 
RestAssured.port + "/pqc/secure");
-                int responseStatus = httpClient.execute(request, 
HttpResponse::getCode);
-
-                if (expectFailure) {
-                    fail(securityProvider + " should have failed but got 
response status : " + responseStatus);
-                } else {
-                    assertTrue(responseStatus == 200, "Expected response 
status is 200");
-                }
+            SSLSocketFactory sslSocketFactory = new SSLSocketFactory(
+                    sslContext,
+                    new String[] { "TLSv1.3" },
+                    null,
+                    SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
+
+            LOG.info("Testing with " + securityProvider + " provider on port " 
+ RestAssured.port);
+
+            int responseStatus = given()
+                    .config(RestAssuredConfig.config().sslConfig(
+                            
SSLConfig.sslConfig().sslSocketFactory(sslSocketFactory)))
+                    .baseUri("https://localhost:"; + RestAssured.port)
+                    .when()
+                    .get("/pqc/secure")
+                    .then()
+                    .extract()
+                    .statusCode();
+
+            if (expectFailure) {
+                fail(securityProvider + " should have failed but got response 
status : " + responseStatus);
+            } else {
+                assertTrue(responseStatus == 200, "Expected response status is 
200");
             }
         } catch (NoClassDefFoundError | ExceptionInInitializerError | 
javax.net.ssl.SSLHandshakeException
-                | org.apache.hc.client5.http.HttpHostConnectException e) {
-            assertTrue(e.getMessage().toLowerCase().contains("connection 
refused"),
+                | java.net.ConnectException e) {
+            String message = e.getMessage().toLowerCase();
+            assertTrue(message.contains("connection refused") || 
message.contains("handshake_failure"),
                     "Different reason - '%s' - of failure then 
expected".formatted(e.getMessage()));
         }
     }
diff --git a/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcOnlyTest.java 
b/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcOnlyTest.java
index 82eb2adb..0587a360 100644
--- a/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcOnlyTest.java
+++ b/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcOnlyTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 
 /**
- * Test Apache HTTP Client with explicit provider selection on PQC-only server.
+ * Test with explicit JSSE provider selection on PQC-only server.
  *
  * Expected results:
  * - BCJSSE: SUCCESS (supports X25519MLKEM768)
diff --git 
a/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcWithFallbackTest.java 
b/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcWithFallbackTest.java
index 10c0f57f..93647702 100644
--- a/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcWithFallbackTest.java
+++ b/http-pqc-j21/src/test/java/org/acme/http/pqc/PqcWithFallbackTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 
 /**
- * Test Apache HTTP Client with PQC+fallback configuration.
+ * Test with PQC+fallback configuration.
  *
  * Expected results:
  * - BCJSSE: SUCCESS (supports X25519MLKEM768 and fallback)

Reply via email to