You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2023/07/13 16:29:39 UTC
[camel-quarkus] 02/03: [relates #3087] Migrate netty-http module into netty http tests
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit ff464b2e3fe71071b009bd65698be56b01100a9c
Author: Andrej Vano <av...@redhat.com>
AuthorDate: Fri Jun 30 13:21:41 2023 +0200
[relates #3087] Migrate netty-http module into netty http tests
---
integration-tests/http/netty-http/pom.xml | 12 ++
.../component/http/netty/NettyHttpResource.java | 112 +++++++++++++
.../component/http/netty/NettyHttpRoutes.java | 132 +++++++++++++++
.../http/netty}/auth/JaasLoginModule.java | 2 +-
.../http/netty}/auth/TestAuthenticator.java | 2 +-
.../http/netty}/auth/TestRolePrincipal.java | 2 +-
.../component/http/netty}/pojo/UserPojo.java | 2 +-
.../http/netty/it}/NettyHttpJaasTest.java | 7 +-
.../http/netty/it}/NettyHttpJaasTestResource.java | 2 +-
.../component/http/netty/it/NettyHttpTest.java | 141 ++++++++++++++++
.../http/netty/it}/NettyHttpTestResource.java | 2 +-
.../http/netty-http/src/test/resources/config.jaas | 3 +
integration-tests/netty-http/pom.xml | 186 ---------------------
.../component/netty/http/NettyHttpResource.java | 152 -----------------
.../component/netty/http/NettyHttpRoutes.java | 156 -----------------
.../component/netty/http/NettyHttpAuthIT.java | 23 ---
.../component/netty/http/NettyHttpAuthTest.java | 65 -------
.../quarkus/component/netty/http/NettyHttpIT.java | 23 ---
.../component/netty/http/NettyHttpJaasIT.java | 23 ---
.../component/netty/http/NettyHttpRestIT.java | 23 ---
.../component/netty/http/NettyHttpRestTest.java | 58 -------
.../component/netty/http/NettyHttpTest.java | 80 ---------
.../netty-http/src/test/resources/config.jaas | 3 -
integration-tests/pom.xml | 1 -
tooling/scripts/test-categories.yaml | 1 -
25 files changed, 411 insertions(+), 802 deletions(-)
diff --git a/integration-tests/http/netty-http/pom.xml b/integration-tests/http/netty-http/pom.xml
index f0333eb2d0..28fad55e23 100644
--- a/integration-tests/http/netty-http/pom.xml
+++ b/integration-tests/http/netty-http/pom.xml
@@ -48,6 +48,18 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jaxb</artifactId>
+ </dependency>
</dependencies>
<profiles>
<profile>
diff --git a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java
index bd73a38713..e482ddce8a 100644
--- a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java
@@ -18,20 +18,29 @@ package org.apache.camel.quarkus.component.http.netty;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
import java.util.zip.GZIPInputStream;
+import io.netty.handler.codec.http.FullHttpResponse;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.camel.Exchange;
+import org.apache.camel.component.netty.http.NettyHttpMessage;
import org.apache.camel.quarkus.component.http.common.AbstractHttpResource;
import org.apache.camel.util.IOHelper;
@@ -119,4 +128,107 @@ public class NettyHttpResource extends AbstractHttpResource {
.send();
return exchange.getException().getClass().getName();
}
+
+ @GET
+ @Path("/getRequest/{method}/{hName}/{hValue}/{body}")
+ public String getRequest(@PathParam("method") String method, @PathParam("hName") String headerName,
+ @PathParam("hValue") String headerValue,
+ @PathParam("body") String body,
+ @QueryParam("test-port") int port) {
+ return producerTemplate.toF("netty-http:http://localhost:%d/request", port)
+ .withHeaders(Map.of(Exchange.HTTP_METHOD, method, headerName, headerValue))
+ .withBody(body)
+ .request(String.class);
+ }
+
+ @GET
+ @Path("/getResponse/{message}")
+ public String getResponse(@PathParam("message") String message, @QueryParam("test-port") int port) {
+ Exchange exchange = producerTemplate.toF("netty-http:http://localhost:%d/response", port)
+ .withBody(message)
+ .send();
+ FullHttpResponse response = exchange.getIn().getBody(NettyHttpMessage.class).getHttpResponse();
+ String received = exchange.getIn().getBody(String.class);
+ return received + ": " + response.status().reasonPhrase() + " " + response.status().code();
+ }
+
+ @GET
+ @Path("/wildcard/{path}")
+ public String wildcard(@PathParam("path") String path, @QueryParam("test-port") int port) {
+ return producerTemplate.toF("netty-http:http://localhost:%d/%s", port, path)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .request(String.class);
+ }
+
+ @GET
+ @Path("/consumer-proxy")
+ public String proxy(@QueryParam("test-port") int port, @QueryParam("proxy-port") int proxyPort) {
+ final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", proxyPort));
+ final String url = "http://localhost:" + port + "/proxy";
+
+ try {
+ final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(proxy);
+ return new String(connection.getInputStream().readAllBytes());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @GET
+ @Path("/auth/{path}/{user}/{password}")
+ public Response auth(@QueryParam("test-port") int port, @PathParam("path") String path, @PathParam("user") String user,
+ @PathParam("password") String password) {
+ final Exchange exchange = producerTemplate.toF("netty-http:http://localhost:%d/%s", port, path)
+ .withHeaders(getAuthHeaders(user, password))
+ .send();
+
+ return Response.status(exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class)).build();
+ }
+
+ @GET
+ @Path("/rest/{method}")
+ public String rest(@QueryParam("rest-port") int port, @PathParam("method") String method) {
+ return producerTemplate.toF("netty-http:http://localhost:%d/rest", port)
+ .withHeader(Exchange.HTTP_METHOD, method)
+ .request(String.class);
+ }
+
+ @GET
+ @Path("/rest/pojo/{type}")
+ public String restPojo(@QueryParam("rest-port") int port, @PathParam("type") String type) {
+ final String body;
+ final String contentType;
+ if ("json".equals(type)) {
+ body = "{\"firstName\":\"John\", \"lastName\":\"Doe\"}";
+ contentType = "application/json";
+ } else {
+ body = "<user firstName=\"John\" lastName=\"Doe\"/>";
+ contentType = "text/xml";
+ }
+ return producerTemplate.toF("netty-http:http://localhost:%d/rest/%s", port, type)
+ .withBody(body)
+ .withHeaders(Map.of(Exchange.HTTP_METHOD, "POST", "Content-Type", contentType))
+ .request(String.class);
+ }
+
+ @GET
+ @Path("/jaas/{user}/{password}")
+ public Response auth(@QueryParam("test-port") int port, @PathParam("user") String user,
+ @PathParam("password") String password) {
+ final Exchange exchange = producerTemplate
+ .toF("netty-http:http://localhost:%d/jaas", port)
+ .withHeaders(getAuthHeaders(user, password))
+ .send();
+
+ return Response.status(exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class)).build();
+ }
+
+ private Map<String, Object> getAuthHeaders(String user, String password) {
+ Map<String, Object> headers = new HashMap<>();
+ headers.put(Exchange.HTTP_METHOD, "GET");
+ if (!"null".equals(user)) {
+ headers.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((user + ":" + password).getBytes()));
+ }
+ return headers;
+ }
}
diff --git a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
index 4cd8de559c..227a23301b 100644
--- a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
@@ -16,11 +16,95 @@
*/
package org.apache.camel.quarkus.component.http.netty;
+import java.nio.charset.Charset;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import io.netty.handler.codec.http.FullHttpRequest;
import io.quarkus.runtime.annotations.RegisterForReflection;
+import jakarta.inject.Named;
+import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty.http.JAASSecurityAuthenticator;
+import org.apache.camel.component.netty.http.NettyHttpComponent;
+import org.apache.camel.component.netty.http.NettyHttpConfiguration;
+import org.apache.camel.component.netty.http.NettyHttpMessage;
+import org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration;
+import org.apache.camel.component.netty.http.SecurityConstraintMapping;
+import org.apache.camel.component.rest.RestConstants;
+import org.apache.camel.model.rest.RestBindingMode;
+import org.apache.camel.quarkus.component.http.netty.auth.TestAuthenticator;
+import org.apache.camel.quarkus.component.http.netty.pojo.UserPojo;
+import org.eclipse.microprofile.config.ConfigProvider;
@RegisterForReflection(targets = IllegalStateException.class, serialization = true)
public class NettyHttpRoutes extends RouteBuilder {
+ @Named("jaasConfig")
+ NettyHttpSecurityConfiguration jaasConfig() {
+ final NettyHttpSecurityConfiguration config = new NettyHttpSecurityConfiguration();
+ config.setRealm("Quarkus");
+ JAASSecurityAuthenticator jaas = new JAASSecurityAuthenticator();
+ jaas.setName("Quarkus");
+ config.setSecurityAuthenticator(jaas);
+ return config;
+ }
+
+ @Named("securityConfig")
+ NettyHttpSecurityConfiguration securityConfiguration() {
+ final NettyHttpSecurityConfiguration config = new NettyHttpSecurityConfiguration();
+ config.setRealm("Quarkus");
+ config.setSecurityAuthenticator(new TestAuthenticator());
+ return config;
+ }
+
+ // Each ACL configuration is using a separate route/endpoint, so all of them are using /* mapping
+ @Named("acladmin")
+ NettyHttpSecurityConfiguration aclAdmin() {
+ final NettyHttpSecurityConfiguration config = securityConfiguration();
+ SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
+ securityConstraintMapping.addInclusion("/*", "admin");
+ config.setSecurityConstraint(securityConstraintMapping);
+ return config;
+ }
+
+ @Named("aclguest")
+ NettyHttpSecurityConfiguration aclGuest() {
+ final NettyHttpSecurityConfiguration config = securityConfiguration();
+ SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
+ securityConstraintMapping.addInclusion("/*", "admin,guest");
+ config.setSecurityConstraint(securityConstraintMapping);
+ return config;
+ }
+
+ @Named("aclpublic")
+ NettyHttpSecurityConfiguration aclPublic() {
+ final NettyHttpSecurityConfiguration config = securityConfiguration();
+ SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
+ securityConstraintMapping.addExclusion("/*");
+ config.setSecurityConstraint(securityConstraintMapping);
+ return config;
+ }
+
+ @Named("aclwildcard")
+ NettyHttpSecurityConfiguration aclWildcard() {
+ final NettyHttpSecurityConfiguration config = securityConfiguration();
+ SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
+ securityConstraintMapping.addInclusion("/*", "*");
+ config.setSecurityConstraint(securityConstraintMapping);
+ return config;
+ }
+
+ @Named("netty-http")
+ NettyHttpComponent component() {
+ NettyHttpComponent component = new NettyHttpComponent();
+ NettyHttpConfiguration config = new NettyHttpConfiguration();
+ // This helps to stabilize the tests when running on windows, as occasionally when invoking the same route from a parameterized test,
+ // the next request got the same channel as the previous request that was not fully done yet and it caused the next test to fail.
+ config.setReuseChannel(true);
+ component.setConfiguration(config);
+ return component;
+ }
+
@Override
public void configure() throws Exception {
from("direct:https")
@@ -31,5 +115,53 @@ public class NettyHttpRoutes extends RouteBuilder {
.throwException(new IllegalStateException("Forced exception"));
from("netty-http:http://0.0.0.0:{{camel.netty-http.compression-test-port}}/compressed?compression=true")
.transform().constant("Netty Hello World Compressed");
+
+ restConfiguration().component("netty-http")
+ .host("localhost").port(ConfigProvider.getConfig().getValue("camel.netty-http.restPort", Integer.class));
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/request")
+ .process(ex -> {
+ final FullHttpRequest req = ex.getIn(NettyHttpMessage.class).getHttpRequest();
+ ex.getIn().setBody(
+ String.join(",", req.method().name(), req.content().toString(Charset.defaultCharset()),
+ StreamSupport.stream(req.headers().spliterator(), false)
+ .map(h -> h.getKey() + ":" + h.getValue()).collect(Collectors.joining(","))));
+ });
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/response").transform().simple("Received message ${body}");
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/auth?securityConfiguration=#securityConfig").log("success");
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/jaas?securityConfiguration=#jaasConfig").log("success");
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/admin?securityConfiguration=#acladmin").log("success");
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/guest?securityConfiguration=#aclguest").log("success");
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/wildcard?securityConfiguration=#aclwildcard")
+ .log("success");
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/public?securityConfiguration=#aclpublic")
+ .log("success");
+
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/wildcard?matchOnUriPrefix=true").setBody()
+ .constant("wildcard matched");
+
+ from("netty-http:proxy://localhost:{{camel.netty-http.proxyPort}}?reuseChannel=false")
+ .toD("netty-http:http://${headers." + Exchange.HTTP_HOST + "}:${headers." + Exchange.HTTP_PORT + "}/${headers."
+ + Exchange.HTTP_PATH + "}");
+ from("netty-http:http://localhost:{{camel.netty-http.port}}/proxy").setBody().constant("proxy");
+
+ rest("/rest")
+ .get("/").to("direct:printMethod")
+ .post("/").to("direct:printMethod")
+ .put("/").to("direct:printMethod")
+ .post("/json").bindingMode(RestBindingMode.json).consumes("application/json").type(UserPojo.class)
+ .to("direct:printBody")
+ .post("/xml").bindingMode(RestBindingMode.xml).consumes("application/xml").type(UserPojo.class)
+ .to("direct:printBody");
+
+ from("direct:printMethod").setBody().header(RestConstants.HTTP_METHOD);
+ from("direct:printBody").process(e -> {
+ e.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
+ e.getIn().setBody(e.getIn().getBody(UserPojo.class).toString());
+ });
}
}
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/JaasLoginModule.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/JaasLoginModule.java
similarity index 97%
rename from integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/JaasLoginModule.java
rename to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/JaasLoginModule.java
index 5190c64b45..70ff53f6bf 100644
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/JaasLoginModule.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/JaasLoginModule.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http.auth;
+package org.apache.camel.quarkus.component.http.netty.auth;
import java.util.Map;
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestAuthenticator.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestAuthenticator.java
similarity index 97%
rename from integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestAuthenticator.java
rename to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestAuthenticator.java
index ff68835fa2..c41dc3e7b8 100644
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestAuthenticator.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestAuthenticator.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http.auth;
+package org.apache.camel.quarkus.component.http.netty.auth;
import java.security.Principal;
import java.util.Arrays;
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestRolePrincipal.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestRolePrincipal.java
similarity index 94%
rename from integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestRolePrincipal.java
rename to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestRolePrincipal.java
index 99c6d4fe12..a18f7c8192 100644
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/auth/TestRolePrincipal.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/auth/TestRolePrincipal.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http.auth;
+package org.apache.camel.quarkus.component.http.netty.auth;
import java.security.Principal;
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/pojo/UserPojo.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/pojo/UserPojo.java
similarity index 96%
rename from integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/pojo/UserPojo.java
rename to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/pojo/UserPojo.java
index 89d524b72d..c4b3fa00a9 100644
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/pojo/UserPojo.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/pojo/UserPojo.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http.pojo;
+package org.apache.camel.quarkus.component.http.netty.pojo;
import io.quarkus.runtime.annotations.RegisterForReflection;
import jakarta.xml.bind.annotation.XmlAccessType;
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTest.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTest.java
similarity index 80%
rename from integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTest.java
rename to integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTest.java
index 22ee6e86b5..e973865eda 100644
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTest.java
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTest.java
@@ -14,11 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http;
+package org.apache.camel.quarkus.component.http.netty.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
@@ -32,8 +33,10 @@ public class NettyHttpJaasTest {
})
public void testJaas(String user, String password, int responseCode) {
RestAssured
+ .given()
+ .queryParam("test-port", ConfigProvider.getConfig().getValue("camel.netty-http.port", Integer.class))
.when()
- .get("/netty/http/jaas/{user}/{password}", user, password)
+ .get("/test/client/netty-http/jaas/{user}/{password}", user, password)
.then()
.statusCode(responseCode);
}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTestResource.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTestResource.java
similarity index 97%
rename from integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTestResource.java
rename to integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTestResource.java
index d2dea0476e..03acb949c9 100644
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasTestResource.java
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpJaasTestResource.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http;
+package org.apache.camel.quarkus.component.http.netty.it;
import java.io.IOException;
import java.io.InputStream;
diff --git a/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java
index 23946f80a9..4b708ed845 100644
--- a/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java
@@ -16,18 +16,27 @@
*/
package org.apache.camel.quarkus.component.http.netty.it;
+import java.util.List;
+
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import io.restassured.response.Response;
+import io.restassured.response.ValidatableResponse;
import org.apache.camel.quarkus.component.http.common.AbstractHttpTest;
import org.apache.camel.quarkus.component.http.common.HttpTestResource;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
@QuarkusTestResource(HttpTestResource.class)
+@QuarkusTestResource(NettyHttpTestResource.class)
public class NettyHttpTest extends AbstractHttpTest {
@Override
public String component() {
@@ -71,4 +80,136 @@ public class NettyHttpTest extends AbstractHttpTest {
.statusCode(200)
.body(is("Netty Hello World Compressed"));
}
+
+ @Test
+ public void testExtractHttpRequestFromNettyHttpMessage() {
+ final String method = "POST";
+ final String headerName = "testHeaderKey";
+ final String headerValue = "testHeaderValue";
+ final String body = "Test body";
+
+ final Response response = RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .when()
+ .get("/test/client/{component}/getRequest/{method}/{hName}/{hValue}/{body}", component(), method, headerName,
+ headerValue, body);
+ assertThat(response.getStatusCode()).isEqualTo(200);
+ assertThat(response.getBody().print().split(",")).containsAll(List.of(method, body, headerName + ":" + headerValue));
+ }
+
+ @Test
+ public void testExtractHttpResponseFromNettyHttpMessage() {
+ final String message = "httpResponseTest";
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .when()
+ .get("/test/client/{component}/getResponse/{message}", component(), message)
+ .then()
+ .statusCode(200)
+ .body(is("Received message " + message + ": OK 200"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = { "wildcard", "wildcard/example.txt" })
+ public void testWildcardMatching(String path) {
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .when()
+ .get("/test/client/{component}/wildcard/{path}", component(), path)
+ .then()
+ .statusCode(200)
+ .body(is("wildcard matched"));
+ }
+
+ @Test
+ public void testProxy() {
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .queryParam("proxy-port", getPort("camel.netty-http.proxyPort"))
+ .when()
+ .get("/test/client/{component}/consumer-proxy", component())
+ .then()
+ .statusCode(200)
+ .body(is("proxy"));
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "null,null,401",
+ "admin,wrongpass,401",
+ "admin,adminpass,200"
+ })
+ public void testCredentials(String user, String password, int responseCode) {
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .when()
+ .get("/test/client/{component}/auth/{path}/{user}/{password}", component(),
+ "auth?securityConfiguration=#securityConfig", user, password)
+ .then()
+ .statusCode(responseCode);
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "admin,admin,adminpass,200",
+ "admin,guest,guestpass,401",
+ "admin,null,null,401",
+ "guest,admin,adminpass,200",
+ "guest,guest,guestpass,200",
+ "guest,null,null,401",
+ "wildcard,admin,adminpass,200",
+ "wildcard,guest,guestpass,200",
+ "wildcard,null,null,401",
+ "public,admin,adminpass,200",
+ "public,guest,guestpass,200",
+ "public,null,null,200",
+ })
+ public void testAcls(String endpoint, String user, String password, int responseCode) {
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.port"))
+ .when()
+ .get("/test/client/{component}/auth/{path}/{user}/{password}", component(),
+ "acls/" + endpoint + "?securityConfiguration=#acl" + endpoint,
+ user, password)
+ .then()
+ .statusCode(responseCode);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = { "GET", "POST", "PUT", "DELETE" })
+ public void testRest(String method) {
+ final ValidatableResponse response = RestAssured
+ .given()
+ .queryParam("rest-port", getPort("camel.netty-http.restPort"))
+ .when()
+ .get("/test/client/{component}/rest/{method}", component(), method)
+ .then();
+ // DELETE is not defined in the routes, so the request should fail
+ if ("DELETE".equals(method)) {
+ response.statusCode(500);
+ } else {
+ response
+ .statusCode(200)
+ .body(is(method));
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = { "json", "xml" })
+ public void pojoTest(String type) {
+ RestAssured
+ .given()
+ .queryParam("rest-port", getPort("camel.netty-http.restPort"))
+ .when()
+ .get("/test/client/{component}/rest/pojo/{type}", component(), type)
+ .then()
+ .statusCode(200)
+ .body(is("Received: John Doe"));
+ }
}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTestResource.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTestResource.java
similarity index 96%
rename from integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTestResource.java
rename to integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTestResource.java
index fbebc89b7d..d6e9cd5e4f 100644
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTestResource.java
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTestResource.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.netty.http;
+package org.apache.camel.quarkus.component.http.netty.it;
import java.util.Map;
import java.util.Objects;
diff --git a/integration-tests/http/netty-http/src/test/resources/config.jaas b/integration-tests/http/netty-http/src/test/resources/config.jaas
new file mode 100644
index 0000000000..fd1ef31fe4
--- /dev/null
+++ b/integration-tests/http/netty-http/src/test/resources/config.jaas
@@ -0,0 +1,3 @@
+Quarkus {
+ org.apache.camel.quarkus.component.http.netty.auth.JaasLoginModule required debug=true;
+};
diff --git a/integration-tests/netty-http/pom.xml b/integration-tests/netty-http/pom.xml
deleted file mode 100644
index 670f3cbcc1..0000000000
--- a/integration-tests/netty-http/pom.xml
+++ /dev/null
@@ -1,186 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
- </parent>
-
- <artifactId>camel-quarkus-integration-test-netty-http</artifactId>
- <name>Camel Quarkus :: Integration Tests :: Netty HTTP</name>
- <description>Integration tests for Camel Quarkus Netty HTTP extension</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-netty-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-rest</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jackson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jaxb</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.rest-assured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- test dependencies - camel-quarkus -->
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-support</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-
- <profiles>
- <profile>
- <id>native</id>
- <activation>
- <property>
- <name>native</name>
- </property>
- </activation>
- <properties>
- <quarkus.package.type>native</quarkus.package.type>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>virtualDependencies</id>
- <activation>
- <property>
- <name>!noVirtualDependencies</name>
- </property>
- </activation>
- <dependencies>
- <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jackson-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jaxb-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-netty-http-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-rest-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-
-</project>
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpResource.java b/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpResource.java
deleted file mode 100644
index 97c8703938..0000000000
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpResource.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.URL;
-import java.util.Base64;
-import java.util.HashMap;
-import java.util.Map;
-
-import io.netty.handler.codec.http.FullHttpResponse;
-import jakarta.inject.Inject;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.core.Response;
-import org.apache.camel.Exchange;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.netty.http.NettyHttpMessage;
-import org.eclipse.microprofile.config.ConfigProvider;
-
-@Path("/netty/http")
-public class NettyHttpResource {
- @Inject
- ProducerTemplate producerTemplate;
-
- @GET
- @Path("/getRequest/{method}/{hName}/{hValue}/{body}")
- public String getRequest(@PathParam("method") String method, @PathParam("hName") String headerName,
- @PathParam("hValue") String headerValue,
- @PathParam("body") String body) {
- return producerTemplate.requestBodyAndHeaders(
- "netty-http:http://localhost:{{camel.netty-http.port}}/request",
- body,
- Map.of(Exchange.HTTP_METHOD, method, headerName, headerValue),
- String.class);
- }
-
- @GET
- @Path("/getResponse/{message}")
- public String getResponse(@PathParam("message") String message) {
- final Exchange exchange = producerTemplate
- .send("netty-http:http://localhost:{{camel.netty-http.port}}/response", ex -> {
- ex.getIn().setBody(message);
- });
- FullHttpResponse response = exchange.getIn().getBody(NettyHttpMessage.class).getHttpResponse();
- String received = exchange.getIn().getBody(String.class);
- return received + ": " + response.status().reasonPhrase() + " " + response.status().code();
- }
-
- @GET
- @Path("/auth/{path}/{user}/{password}")
- public Response auth(@PathParam("path") String path, @PathParam("user") String user,
- @PathParam("password") String password) {
- final Exchange exchange = producerTemplate
- .send("netty-http:http://localhost:{{camel.netty-http.port}}/" + path,
- ex -> ex.getIn().setHeaders(getAuthHeaders(user, password)));
-
- return Response.status(exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class)).build();
- }
-
- @GET
- @Path("/jaas/{user}/{password}")
- public Response auth(@PathParam("user") String user, @PathParam("password") String password) {
- final Exchange exchange = producerTemplate
- .send("netty-http:http://localhost:{{camel.netty-http.port}}/jaas",
- ex -> ex.getIn().setHeaders(getAuthHeaders(user, password)));
-
- return Response.status(exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class)).build();
- }
-
- @GET
- @Path("/wildcard/{path}")
- public Response wildcard(@PathParam("path") String path) {
- final String body = producerTemplate.requestBodyAndHeader(
- "netty-http:http://localhost:{{camel.netty-http.port}}/" + path,
- null, Exchange.HTTP_METHOD, "GET", String.class);
- return Response.ok(body).build();
- }
-
- @GET
- @Path("/proxy")
- public String proxy() {
- final int proxyPort = ConfigProvider.getConfig().getValue("camel.netty-http.proxyPort", Integer.class);
- final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", proxyPort));
-
- final int port = ConfigProvider.getConfig().getValue("camel.netty-http.port", Integer.class);
- final String url = "http://localhost:" + port + "/proxy";
-
- try {
- final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(proxy);
- return new String(connection.getInputStream().readAllBytes());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @GET
- @Path("/rest/{method}")
- public String rest(@PathParam("method") String method) {
- return producerTemplate.requestBodyAndHeader(
- "netty-http:http://localhost:{{camel.netty-http.restPort}}/rest",
- null,
- Exchange.HTTP_METHOD, method,
- String.class);
- }
-
- @GET
- @Path("/rest/pojo/{type}")
- public String restPojo(@PathParam("type") String type) {
- final String body;
- final String contentType;
- if ("json".equals(type)) {
- body = "{\"firstName\":\"John\", \"lastName\":\"Doe\"}";
- contentType = "application/json";
- } else {
- body = "<user firstName=\"John\" lastName=\"Doe\"/>";
- contentType = "text/xml";
- }
- return producerTemplate.requestBodyAndHeaders(
- "netty-http:http://localhost:{{camel.netty-http.restPort}}/rest/" + type,
- body,
- Map.of(Exchange.HTTP_METHOD, "POST", "Content-Type", contentType),
- String.class);
- }
-
- private Map<String, Object> getAuthHeaders(String user, String password) {
- Map<String, Object> headers = new HashMap<>();
- headers.put(Exchange.HTTP_METHOD, "GET");
- if (!"null".equals(user)) {
- headers.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((user + ":" + password).getBytes()));
- }
- return headers;
- }
-}
diff --git a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRoutes.java b/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRoutes.java
deleted file mode 100644
index dc2ddaeefb..0000000000
--- a/integration-tests/netty-http/src/main/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRoutes.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import java.nio.charset.Charset;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
-import io.netty.handler.codec.http.FullHttpRequest;
-import jakarta.inject.Named;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.netty.http.JAASSecurityAuthenticator;
-import org.apache.camel.component.netty.http.NettyHttpComponent;
-import org.apache.camel.component.netty.http.NettyHttpConfiguration;
-import org.apache.camel.component.netty.http.NettyHttpMessage;
-import org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration;
-import org.apache.camel.component.netty.http.SecurityConstraintMapping;
-import org.apache.camel.component.rest.RestConstants;
-import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.quarkus.component.netty.http.auth.TestAuthenticator;
-import org.apache.camel.quarkus.component.netty.http.pojo.UserPojo;
-import org.eclipse.microprofile.config.ConfigProvider;
-
-public class NettyHttpRoutes extends RouteBuilder {
- @Named("jaasConfig")
- NettyHttpSecurityConfiguration jaasConfig() {
- final NettyHttpSecurityConfiguration config = new NettyHttpSecurityConfiguration();
- config.setRealm("Quarkus");
- JAASSecurityAuthenticator jaas = new JAASSecurityAuthenticator();
- jaas.setName("Quarkus");
- config.setSecurityAuthenticator(jaas);
- return config;
- }
-
- @Named("securityConfig")
- NettyHttpSecurityConfiguration securityConfiguration() {
- final NettyHttpSecurityConfiguration config = new NettyHttpSecurityConfiguration();
- config.setRealm("Quarkus");
- config.setSecurityAuthenticator(new TestAuthenticator());
- return config;
- }
-
- // Each ACL configuration is using a separate route/endpoint, so all of them are using /* mapping
- @Named("acladmin")
- NettyHttpSecurityConfiguration aclAdmin() {
- final NettyHttpSecurityConfiguration config = securityConfiguration();
- SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
- securityConstraintMapping.addInclusion("/*", "admin");
- config.setSecurityConstraint(securityConstraintMapping);
- return config;
- }
-
- @Named("aclguest")
- NettyHttpSecurityConfiguration aclGuest() {
- final NettyHttpSecurityConfiguration config = securityConfiguration();
- SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
- securityConstraintMapping.addInclusion("/*", "admin,guest");
- config.setSecurityConstraint(securityConstraintMapping);
- return config;
- }
-
- @Named("aclpublic")
- NettyHttpSecurityConfiguration aclPublic() {
- final NettyHttpSecurityConfiguration config = securityConfiguration();
- SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
- securityConstraintMapping.addExclusion("/*");
- config.setSecurityConstraint(securityConstraintMapping);
- return config;
- }
-
- @Named("aclwildcard")
- NettyHttpSecurityConfiguration aclWildcard() {
- final NettyHttpSecurityConfiguration config = securityConfiguration();
- SecurityConstraintMapping securityConstraintMapping = new SecurityConstraintMapping();
- securityConstraintMapping.addInclusion("/*", "*");
- config.setSecurityConstraint(securityConstraintMapping);
- return config;
- }
-
- @Named("netty-http")
- NettyHttpComponent component() {
- NettyHttpComponent component = new NettyHttpComponent();
- NettyHttpConfiguration config = new NettyHttpConfiguration();
- // This helps to stabilize the tests when running on windows, as occasionally when invoking the same route from a parameterized test,
- // the next request got the same channel as the previous request that was not fully done yet and it caused the next test to fail.
- config.setReuseChannel(true);
- component.setConfiguration(config);
- return component;
- }
-
- @Override
- public void configure() throws Exception {
- restConfiguration().component("netty-http")
- .host("localhost").port(ConfigProvider.getConfig().getValue("camel.netty-http.restPort", Integer.class));
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/request")
- .process(ex -> {
- final FullHttpRequest req = ex.getIn(NettyHttpMessage.class).getHttpRequest();
- ex.getIn().setBody(
- String.join(",", req.method().name(), req.content().toString(Charset.defaultCharset()),
- StreamSupport.stream(req.headers().spliterator(), false)
- .map(h -> h.getKey() + ":" + h.getValue()).collect(Collectors.joining(","))));
- });
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/response").transform().simple("Received message ${body}");
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/auth?securityConfiguration=#securityConfig").log("success");
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/jaas?securityConfiguration=#jaasConfig").log("success");
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/admin?securityConfiguration=#acladmin").log("success");
- from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/guest?securityConfiguration=#aclguest").log("success");
- from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/wildcard?securityConfiguration=#aclwildcard")
- .log("success");
- from("netty-http:http://localhost:{{camel.netty-http.port}}/acls/public?securityConfiguration=#aclpublic")
- .log("success");
-
- from("netty-http:http://localhost:{{camel.netty-http.port}}/wildcard?matchOnUriPrefix=true").setBody()
- .constant("wildcard matched");
-
- from("netty-http:proxy://localhost:{{camel.netty-http.proxyPort}}?reuseChannel=false")
- .toD("netty-http:http://${headers." + Exchange.HTTP_HOST + "}:${headers." + Exchange.HTTP_PORT + "}/${headers."
- + Exchange.HTTP_PATH + "}");
- from("netty-http:http://localhost:{{camel.netty-http.port}}/proxy").setBody().constant("proxy");
-
- rest("/rest")
- .get("/").to("direct:printMethod")
- .post("/").to("direct:printMethod")
- .put("/").to("direct:printMethod")
- .post("/json").bindingMode(RestBindingMode.json).consumes("application/json").type(UserPojo.class)
- .to("direct:printBody")
- .post("/xml").bindingMode(RestBindingMode.xml).consumes("application/xml").type(UserPojo.class)
- .to("direct:printBody");
-
- from("direct:printMethod").setBody().header(RestConstants.HTTP_METHOD);
- from("direct:printBody").process(e -> {
- e.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
- e.getIn().setBody(e.getIn().getBody(UserPojo.class).toString());
- });
- }
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthIT.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthIT.java
deleted file mode 100644
index 4944ad88ef..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthIT.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class NettyHttpAuthIT extends NettyHttpAuthTest {
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthTest.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthTest.java
deleted file mode 100644
index 29baf0651c..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpAuthTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-
-@QuarkusTest
-@QuarkusTestResource(NettyHttpTestResource.class)
-public class NettyHttpAuthTest {
- @ParameterizedTest
- @CsvSource({
- "null,null,401",
- "admin,wrongpass,401",
- "admin,adminpass,200"
- })
- public void testCredentials(String user, String password, int responseCode) {
- RestAssured
- .when()
- .get("/netty/http/auth/{path}/{user}/{password}", "auth?securityConfiguration=#securityConfig", user, password)
- .then()
- .statusCode(responseCode);
- }
-
- @ParameterizedTest
- @CsvSource({
- "admin,admin,adminpass,200",
- "admin,guest,guestpass,401",
- "admin,null,null,401",
- "guest,admin,adminpass,200",
- "guest,guest,guestpass,200",
- "guest,null,null,401",
- "wildcard,admin,adminpass,200",
- "wildcard,guest,guestpass,200",
- "wildcard,null,null,401",
- "public,admin,adminpass,200",
- "public,guest,guestpass,200",
- "public,null,null,200",
- })
- public void testAcls(String endpoint, String user, String password, int responseCode) {
- RestAssured
- .when()
- .get("/netty/http/auth/{path}/{user}/{password}", "acls/" + endpoint + "?securityConfiguration=#acl" + endpoint,
- user, password)
- .then()
- .statusCode(responseCode);
- }
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpIT.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpIT.java
deleted file mode 100644
index 2fe912ce03..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpIT.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class NettyHttpIT extends NettyHttpTest {
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasIT.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasIT.java
deleted file mode 100644
index 233a6349ae..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpJaasIT.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class NettyHttpJaasIT extends NettyHttpJaasTest {
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestIT.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestIT.java
deleted file mode 100644
index 3b7b76c332..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestIT.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class NettyHttpRestIT extends NettyHttpRestTest {
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestTest.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestTest.java
deleted file mode 100644
index a8daa11d2c..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpRestTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import io.restassured.response.ValidatableResponse;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import static org.hamcrest.Matchers.is;
-
-@QuarkusTest
-@QuarkusTestResource(NettyHttpTestResource.class)
-public class NettyHttpRestTest {
- @ParameterizedTest
- @ValueSource(strings = { "GET", "POST", "PUT", "DELETE" })
- public void testRest(String method) {
- final ValidatableResponse response = RestAssured
- .when()
- .get("/netty/http/rest/{method}", method)
- .then();
- // DELETE is not defined in the routes, so the request should fail
- if ("DELETE".equals(method)) {
- response.statusCode(500);
- } else {
- response
- .statusCode(200)
- .body(is(method));
- }
- }
-
- @ParameterizedTest
- @ValueSource(strings = { "json", "xml" })
- public void pojoTest(String type) {
- RestAssured
- .when()
- .get("/netty/http/rest/pojo/{type}", type)
- .then()
- .statusCode(200)
- .body(is("Received: John Doe"));
- }
-}
diff --git a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTest.java b/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTest.java
deleted file mode 100644
index 55abf2b286..0000000000
--- a/integration-tests/netty-http/src/test/java/org/apache/camel/quarkus/component/netty/http/NettyHttpTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.netty.http;
-
-import java.util.List;
-
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import io.restassured.response.Response;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.is;
-
-@QuarkusTest
-@QuarkusTestResource(NettyHttpTestResource.class)
-public class NettyHttpTest {
- @Test
- public void testExtractHttpRequestFromNettyHttpMessage() {
- final String method = "POST";
- final String headerName = "testHeaderKey";
- final String headerValue = "testHeaderValue";
- final String body = "Test body";
-
- final Response response = RestAssured
- .when()
- .get("/netty/http/getRequest/{method}/{hName}/{hValue}/{body}", method, headerName, headerValue, body);
- assertThat(response.getStatusCode()).isEqualTo(200);
- assertThat(response.getBody().print().split(",")).containsAll(List.of(method, body, headerName + ":" + headerValue));
- }
-
- @Test
- public void testExtractHttpResponseFromNettyHttpMessage() {
- final String message = "httpResponseTest";
- RestAssured
- .when()
- .get("/netty/http/getResponse/{message}", message)
- .then()
- .statusCode(200)
- .body(is("Received message " + message + ": OK 200"));
- }
-
- @ParameterizedTest
- @ValueSource(strings = { "wildcard", "wildcard/example.txt" })
- public void testWildcardMatching(String path) {
- RestAssured
- .when()
- .get("/netty/http/wildcard/{path}", path)
- .then()
- .statusCode(200)
- .body(is("wildcard matched"));
- }
-
- @Test
- public void testProxy() {
- RestAssured
- .when()
- .get("/netty/http/proxy")
- .then()
- .statusCode(200)
- .body(is("proxy"));
- }
-}
diff --git a/integration-tests/netty-http/src/test/resources/config.jaas b/integration-tests/netty-http/src/test/resources/config.jaas
deleted file mode 100644
index 1e659b9614..0000000000
--- a/integration-tests/netty-http/src/test/resources/config.jaas
+++ /dev/null
@@ -1,3 +0,0 @@
-Quarkus {
- org.apache.camel.quarkus.component.netty.http.auth.JaasLoginModule required debug=true;
-};
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index c95f6dfd4f..7f092b05aa 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -172,7 +172,6 @@
<module>mybatis</module>
<module>nats</module>
<module>netty</module>
- <module>netty-http</module>
<module>nitrite</module>
<module>oaipmh</module>
<module>ognl</module>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index ce65adffbb..a59409ad0f 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -174,7 +174,6 @@ group-11:
- jsonata
- mustache
- netty
- - netty-http
- qute
- servlet
- stringtemplate