This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new a1397adfc2 Add http non proxy host tests usecase
a1397adfc2 is described below
commit a1397adfc2af2b8066c62f8f159547565476bed5
Author: Souvik Ghosh <[email protected]>
AuthorDate: Wed Mar 18 13:33:48 2026 +0530
Add http non proxy host tests usecase
---
.../quarkus/component/http/http/HttpResource.java | 19 +++++++++++
.../quarkus/component/http/http/it/HttpTest.java | 38 ++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git
a/integration-test-groups/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
b/integration-test-groups/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
index a08b111b4e..1d8b0b51b7 100644
---
a/integration-test-groups/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
+++
b/integration-test-groups/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
@@ -120,6 +120,25 @@ public class HttpResource extends AbstractHttpResource {
.request(String.class);
}
+ @Path("/nonProxy")
+ @GET
+ @Produces(MediaType.APPLICATION_XML)
+ public String nonProxy(@QueryParam("non-proxy-hosts") String
nonProxyHosts, @QueryParam("proxy-host") String proxyHost,
+ @QueryParam("proxy-port") int proxyPort) {
+ return producerTemplate
+ .toF("%s?"
+ + "proxyAuthMethod=Basic"
+ + "&proxyAuthScheme=http"
+ + "&proxyAuthHost=%s"
+ + "&proxyAuthPort=%d"
+ + "&proxyAuthUsername=%s"
+ + "&proxyAuthPassword=%s"
+ + "&nonProxyHosts=%s", String.format(PROXIED_URL,
"http"),
+ proxyHost, proxyPort, USER_ADMIN,
+ USER_ADMIN_PASSWORD, nonProxyHosts)
+ .request(String.class);
+ }
+
@Path("/send-dynamic")
@GET
@Produces(MediaType.APPLICATION_JSON)
diff --git
a/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
b/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
index 2f6a58252c..913faf9b24 100644
---
a/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
+++
b/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.http.http.it;
+import java.util.stream.Stream;
+
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
@@ -25,11 +27,16 @@ import io.smallrye.certs.junit5.Certificate;
import org.apache.camel.quarkus.component.http.common.AbstractHttpTest;
import org.apache.camel.quarkus.component.http.common.HttpTestResource;
import org.apache.camel.quarkus.test.support.certificate.TestCertificates;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
@TestCertificates(certificates = {
@Certificate(name = HttpTestResource.KEYSTORE_NAME, formats = {
@@ -91,4 +98,35 @@ public class HttpTest extends AbstractHttpTest {
.body(is("Compressed response"));
}
+ @ParameterizedTest
+ @MethodSource("proxyProviders")
+ void testNonProxyRouting(String nonProxyHosts, int proxyPort, String
proxyHost, int status, String expectedBody) {
+ var response = RestAssured.given()
+ .queryParam("non-proxy-hosts", nonProxyHosts)
+ .queryParam("proxy-port", proxyPort)
+ .queryParam("proxy-host", proxyHost)
+ .when()
+ .get("/test/client/{component}/nonProxy", component())
+ .then()
+ .statusCode(status);
+
+ // Only check the body if an expected value was provided and not null
+ if (expectedBody != null) {
+ response.body("metadata.groupId", is(expectedBody));
+ }
+ }
+
+ static Stream<Arguments> proxyProviders() {
+ var config = ConfigProvider.getConfig();
+ String host = config.getValue("proxy.host", String.class);
+ int actualPort = config.getValue("proxy.port", Integer.class);
+ int fakePort = RestAssured.port;
+ String expectedGroupId = "org.apache.camel.quarkus";
+
+ return Stream.of(
+ arguments("repo.maven.apache.org", actualPort, host, 200,
expectedGroupId),
+ arguments("*.apache.org", fakePort, host, 200,
expectedGroupId),
+ arguments("*localhost*", fakePort, host, 500, null));
+ }
+
}