|
16 | 16 | */ |
17 | 17 | package org.apache.camel.quarkus.component.http.http.it; |
18 | 18 |
|
| 19 | +import java.util.stream.Stream; |
| 20 | + |
19 | 21 | import io.quarkus.test.common.QuarkusTestResource; |
20 | 22 | import io.quarkus.test.junit.QuarkusTest; |
21 | 23 | import io.restassured.RestAssured; |
|
25 | 27 | import org.apache.camel.quarkus.component.http.common.AbstractHttpTest; |
26 | 28 | import org.apache.camel.quarkus.component.http.common.HttpTestResource; |
27 | 29 | import org.apache.camel.quarkus.test.support.certificate.TestCertificates; |
| 30 | +import org.eclipse.microprofile.config.ConfigProvider; |
28 | 31 | import org.junit.jupiter.api.Test; |
| 32 | +import org.junit.jupiter.params.ParameterizedTest; |
| 33 | +import org.junit.jupiter.params.provider.Arguments; |
| 34 | +import org.junit.jupiter.params.provider.MethodSource; |
29 | 35 |
|
30 | 36 | import static org.hamcrest.Matchers.empty; |
31 | 37 | import static org.hamcrest.Matchers.is; |
32 | 38 | import static org.hamcrest.Matchers.not; |
| 39 | +import static org.junit.jupiter.params.provider.Arguments.arguments; |
33 | 40 |
|
34 | 41 | @TestCertificates(certificates = { |
35 | 42 | @Certificate(name = HttpTestResource.KEYSTORE_NAME, formats = { |
@@ -91,4 +98,35 @@ public void compression() { |
91 | 98 | .body(is("Compressed response")); |
92 | 99 | } |
93 | 100 |
|
| 101 | + @ParameterizedTest |
| 102 | + @MethodSource("proxyProviders") |
| 103 | + void testNonProxyRouting(String nonProxyHosts, int proxyPort, String proxyHost, int status, String expectedBody) { |
| 104 | + var response = RestAssured.given() |
| 105 | + .queryParam("non-proxy-hosts", nonProxyHosts) |
| 106 | + .queryParam("proxy-port", proxyPort) |
| 107 | + .queryParam("proxy-host", proxyHost) |
| 108 | + .when() |
| 109 | + .get("/test/client/{component}/nonProxy", component()) |
| 110 | + .then() |
| 111 | + .statusCode(status); |
| 112 | + |
| 113 | + // Only check the body if an expected value was provided and not null |
| 114 | + if (expectedBody != null) { |
| 115 | + response.body("metadata.groupId", is(expectedBody)); |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + static Stream<Arguments> proxyProviders() { |
| 120 | + var config = ConfigProvider.getConfig(); |
| 121 | + String host = config.getValue("proxy.host", String.class); |
| 122 | + int actualPort = config.getValue("proxy.port", Integer.class); |
| 123 | + int fakePort = RestAssured.port; |
| 124 | + String expectedGroupId = "org.apache.camel.quarkus"; |
| 125 | + |
| 126 | + return Stream.of( |
| 127 | + arguments("repo.maven.apache.org", actualPort, host, 200, expectedGroupId), |
| 128 | + arguments("*.apache.org", fakePort, host, 200, expectedGroupId), |
| 129 | + arguments("*localhost*", fakePort, host, 500, null)); |
| 130 | + } |
| 131 | + |
94 | 132 | } |
0 commit comments