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

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


The following commit(s) were added to refs/heads/2.13.x by this push:
     new 3051e9e923 Platform-http : add integration tests for reverse proxy 
feature Fixes #4246
3051e9e923 is described below

commit 3051e9e923ebcf967f8a621aa4a5407d7b1ab54a
Author: Zineb Bendhiba <bendhiba.zi...@gmail.com>
AuthorDate: Fri Oct 7 14:03:44 2022 +0200

    Platform-http : add integration tests for reverse proxy feature
    Fixes #4246
---
 .../pages/reference/extensions/platform-http.adoc  |  15 +++
 .../platform-http/runtime/src/main/doc/usage.adoc  |  14 +++
 integration-tests/platform-http-proxy-ssl/pom.xml  | 136 ++++++++++++++++++++
 .../proxy/ssl/it/PlatformHttpProxySslResource.java |  37 ++++++
 .../platform/http/proxy/ssl/it/Routes.java         |  77 ++++++++++++
 .../src/main/resources/application.properties      |  19 +++
 .../src/main/resources/ssl/keystore.p12            | Bin 0 -> 2716 bytes
 .../PlatformHttpSSLTestResource.java               |  59 +++++++++
 .../ProxySslTest.java                              |  57 +++++++++
 .../ProxyTestIT.java                               |  23 ++++
 .../test/resources/mappings/originServer_GET.json  |  18 +++
 .../test/resources/mappings/originServer_POST.json |  18 +++
 integration-tests/platform-http-proxy/pom.xml      | 138 +++++++++++++++++++++
 .../http/proxy/it/PlatformHttpProxyResource.java   |  37 ++++++
 .../component/platform/http/proxy/it/Routes.java   |  34 +++++
 .../http/proxy/it/PlatformHttpTestResource.java    |  47 +++++++
 .../platform/http/proxy/it/ProxyTest.java          |  60 +++++++++
 .../platform/http/proxy/it/ProxyTestIT.java        |  23 ++++
 .../test/resources/mappings/originServer_GET.json  |  18 +++
 .../test/resources/mappings/originServer_POST.json |  18 +++
 integration-tests/pom.xml                          |   2 +
 tooling/scripts/test-categories.yaml               |   2 +
 22 files changed, 852 insertions(+)

diff --git a/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc 
b/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc
index af1c221437..25be1753e9 100644
--- a/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc
@@ -136,6 +136,21 @@ from("platform-http:/secure")
 Also check the `quarkus.http.body.*` configuration options in
 
https://quarkus.io/guides/all-config#quarkus-vertx-http_quarkus-vertx-http-eclipse-vert.x-http[Quarkus
 documentation], esp. `quarkus.http.body.handle-file-uploads`, 
`quarkus.http.body.uploads-directory` and 
`quarkus.http.body.delete-uploaded-files-on-end`.
 
+[id="extensions-platform-http-usage-implementing-a-reverse-proxy"]
+=== Implementing a reverse proxy
+
+Platform HTTP component can act as a reverse proxy, in that case 
`Exchange.HTTP_URI`, `Exchange.HTTP_HOST` headers are populated from the 
absolute URL received on the request line of the HTTP request.
+
+Here's an example of a HTTP proxy that simply redirects the Exchange to the 
origin server.
+
+[source,java]
+------------------------------------------------------------------------------------------
+from("platform-http:proxy")
+    .toD("http://";
+        + "${headers." + Exchange.HTTP_HOST + "}");
+
+-------------------------------------------------------------------------------------
+
 
 [id="extensions-platform-http-additional-camel-quarkus-configuration"]
 == Additional Camel Quarkus configuration
diff --git a/extensions/platform-http/runtime/src/main/doc/usage.adoc 
b/extensions/platform-http/runtime/src/main/doc/usage.adoc
index 7fd9d9ee0f..f324692afb 100644
--- a/extensions/platform-http/runtime/src/main/doc/usage.adoc
+++ b/extensions/platform-http/runtime/src/main/doc/usage.adoc
@@ -79,3 +79,17 @@ from("platform-http:/secure")
 
 Also check the `quarkus.http.body.*` configuration options in
 
https://quarkus.io/guides/all-config#quarkus-vertx-http_quarkus-vertx-http-eclipse-vert.x-http[Quarkus
 documentation], esp. `quarkus.http.body.handle-file-uploads`, 
`quarkus.http.body.uploads-directory` and 
`quarkus.http.body.delete-uploaded-files-on-end`.
+
+=== Implementing a reverse proxy
+
+Platform HTTP component can act as a reverse proxy, in that case 
`Exchange.HTTP_URI`, `Exchange.HTTP_HOST` headers are populated from the 
absolute URL received on the request line of the HTTP request.
+
+Here's an example of a HTTP proxy that simply redirects the Exchange to the 
origin server.
+
+[source,java]
+------------------------------------------------------------------------------------------
+from("platform-http:proxy")
+    .toD("http://";
+        + "${headers." + Exchange.HTTP_HOST + "}");
+
+-------------------------------------------------------------------------------------
diff --git a/integration-tests/platform-http-proxy-ssl/pom.xml 
b/integration-tests/platform-http-proxy-ssl/pom.xml
new file mode 100644
index 0000000000..b6dfa31ffb
--- /dev/null
+++ b/integration-tests/platform-http-proxy-ssl/pom.xml
@@ -0,0 +1,136 @@
+<?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>2.13.2-SNAPSHOT</version>
+        <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+    </parent>
+
+    
<artifactId>camel-quarkus-integration-test-platform-http-proxy-ssl</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: Platform HTTP Proxy SSL</name>
+    <description>Integration tests for Camel Quarkus platform-http extension - 
Proxy - SSL</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-platform-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-http</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>
+        <!-- dependencies needed to mock origin server  -->
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-wiremock-support</artifactId>
+        </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-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-platform-http-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/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/PlatformHttpProxySslResource.java
 
b/integration-tests/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/PlatformHttpProxySslResource.java
new file mode 100644
index 0000000000..cc3b55c0df
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/PlatformHttpProxySslResource.java
@@ -0,0 +1,37 @@
+/*
+ * 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.platform.http.proxy.ssl.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+@Path("/platform-http-proxy-ssl")
+public class PlatformHttpProxySslResource {
+
+    @ConfigProperty(name = "platform.origin.url")
+    String url;
+
+    @GET
+    public String getUrl() {
+        return url;
+    }
+
+}
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/Routes.java
 
b/integration-tests/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/Routes.java
new file mode 100644
index 0000000000..246cbe0930
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/ssl/it/Routes.java
@@ -0,0 +1,77 @@
+/*
+ * 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.platform.http.proxy.ssl.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.jsse.KeyManagersParameters;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+public class Routes extends RouteBuilder {
+
+    @ConfigProperty(name = "platform.origin.url", defaultValue = "TODO")
+    String url;
+
+    @Named
+    @Produces
+    @Singleton
+    public SSLContextParameters sslContextParameters() {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+
+        KeyManagersParameters keyManagersParameters = new 
KeyManagersParameters();
+        KeyStoreParameters keyStore = new KeyStoreParameters();
+        keyStore.setPassword("changeit");
+        keyStore.setResource("ssl/keystore.p12");
+        keyManagersParameters.setKeyPassword("changeit");
+        keyManagersParameters.setKeyStore(keyStore);
+        sslContextParameters.setKeyManagers(keyManagersParameters);
+
+        KeyStoreParameters truststoreParameters = new KeyStoreParameters();
+        truststoreParameters.setResource("ssl/keystore.p12");
+        truststoreParameters.setPassword("changeit");
+
+        TrustManagersParameters trustManagersParameters = new 
TrustManagersParameters();
+        trustManagersParameters.setKeyStore(truststoreParameters);
+        sslContextParameters.setTrustManagers(trustManagersParameters);
+
+        return sslContextParameters;
+    }
+
+    @Named
+    public NoopHostnameVerifier x509HostnameVerifier() {
+        return NoopHostnameVerifier.INSTANCE;
+    }
+
+    @Override
+    public void configure() throws Exception {
+        from("platform-http:proxy")
+                .log("header is :: ${headers.CamelHttpHost}")
+                .log("Im here with body :: ${body}")
+                .toD("https://${headers."; + Exchange.HTTP_HOST
+                        + 
"}?bridgeEndpoint=true&sslContextParameters=#sslContextParameters&x509HostnameVerifier=#x509HostnameVerifier");
+    }
+}
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/main/resources/application.properties
 
b/integration-tests/platform-http-proxy-ssl/src/main/resources/application.properties
new file mode 100644
index 0000000000..bdb7e92643
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/main/resources/application.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+
+quarkus.native.resources.includes=ssl/keystore.p12
\ No newline at end of file
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/main/resources/ssl/keystore.p12 
b/integration-tests/platform-http-proxy-ssl/src/main/resources/ssl/keystore.p12
new file mode 100644
index 0000000000..fadac3cb35
Binary files /dev/null and 
b/integration-tests/platform-http-proxy-ssl/src/main/resources/ssl/keystore.p12 
differ
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/PlatformHttpSSLTestResource.java
 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/PlatformHttpSSLTestResource.java
new file mode 100644
index 0000000000..27b0fa00b5
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/PlatformHttpSSLTestResource.java
@@ -0,0 +1,59 @@
+/*
+ * 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.platform.http.proxy.ssl.it;
+
+import java.util.Map;
+
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import 
org.apache.camel.quarkus.test.wiremock.WireMockTestResourceLifecycleManager;
+
+public class PlatformHttpSSLTestResource extends 
WireMockTestResourceLifecycleManager {
+    private static final String PLATFORM_ORIGIN_HOST = "PLATFORM_ORIGIN_HOST";
+    private static final String PLATFORM_ORIGIN_PORT = "PLATFORM_ORIGIN_PORT";
+
+    @Override
+    protected String getRecordTargetBaseUrl() {
+        return "/";
+    }
+
+    @Override
+    protected boolean isMockingEnabled() {
+        return !envVarsPresent(PLATFORM_ORIGIN_HOST, PLATFORM_ORIGIN_PORT);
+    }
+
+    @Override
+    public Map<String, String> start() {
+        Map<String, String> options = super.start();
+        if (options.containsKey("wiremock.url.ssl")) {
+            String wiremockUrl = options.get("wiremock.url.ssl");
+            options.put("platform.origin.url", wiremockUrl);
+        }
+        return options;
+    }
+
+    @Override
+    protected void customizeWiremockConfiguration(WireMockConfiguration 
config) {
+        // add an SSL port
+        config.dynamicHttpsPort();
+        // Either a path to a file or a resource on the classpath
+        config.keystorePath("ssl/keystore.p12");
+        // The password used to access the keystore. Defaults to "password" if 
omitted
+        config.keystorePassword("changeit");
+        // The password used to access individual keys in the keystore. 
Defaults to "password" if omitted
+        config.keyManagerPassword("changeit");
+    }
+}
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxySslTest.java
 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxySslTest.java
new file mode 100644
index 0000000000..8df99de9cf
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxySslTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.platform.http.proxy.ssl.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(PlatformHttpSSLTestResource.class)
+public class ProxySslTest {
+    @Test
+    void test() {
+        final var proxyUrl = "http://localhost:"; + RestAssured.port;
+        String url = given()
+                .get("/platform-http-proxy-ssl")
+                .body().asString();
+
+        // forcing RestAssured to send a GET instead of CONNECT with proxy 
settings
+        url = url.replace("https", "http");
+        given()
+                .proxy(proxyUrl)
+                .contentType(ContentType.JSON)
+                .when().get(url)
+                .then()
+                .statusCode(200)
+                .body(equalTo("{\"message\": \"Hello World!\"}"));
+
+        given()
+                .body("hello")
+                .proxy(proxyUrl)
+                .contentType(ContentType.JSON)
+                .when().post(url)
+                .then()
+                .statusCode(200)
+                .body(equalTo("{\"message\": \"Hello World!\"}"));
+    }
+}
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxyTestIT.java
 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxyTestIT.java
new file mode 100644
index 0000000000..c5cb0e0ba9
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/test/java/org.apache.camel.quarkus.component.platform.http.proxy.ssl.it/ProxyTestIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.platform.http.proxy.ssl.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+public class ProxyTestIT extends ProxySslTest {
+}
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_GET.json
 
b/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_GET.json
new file mode 100644
index 0000000000..4552e75883
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_GET.json
@@ -0,0 +1,18 @@
+{
+  "id": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "name": "platform-http-proxy_api",
+  "request": {
+    "url": "/",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "body": "{\"message\": \"Hello World!\"}",
+    "headers": {
+      "Content-Type": "application/json; charset=UTF-8"
+    }
+  },
+  "uuid": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git 
a/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_POST.json
 
b/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_POST.json
new file mode 100644
index 0000000000..dcfce92e74
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy-ssl/src/test/resources/mappings/originServer_POST.json
@@ -0,0 +1,18 @@
+{
+  "id": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "name": "platform-http-proxy_api",
+  "request": {
+    "url": "/",
+    "method": "POST"
+  },
+  "response": {
+    "status": 200,
+    "body": "{\"message\": \"Hello World!\"}",
+    "headers": {
+      "Content-Type": "application/json; charset=UTF-8"
+    }
+  },
+  "uuid": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/integration-tests/platform-http-proxy/pom.xml 
b/integration-tests/platform-http-proxy/pom.xml
new file mode 100644
index 0000000000..dd41f406fb
--- /dev/null
+++ b/integration-tests/platform-http-proxy/pom.xml
@@ -0,0 +1,138 @@
+<?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>2.13.2-SNAPSHOT</version>
+        <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-quarkus-integration-test-platform-http-proxy</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: Platform HTTP Proxy</name>
+    <description>Integration tests for Camel Quarkus platform-http extension - 
Proxy</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-platform-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-http</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>
+        <!-- dependencies needed to mock origin server  -->
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-wiremock-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-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-platform-http-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/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpProxyResource.java
 
b/integration-tests/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpProxyResource.java
new file mode 100644
index 0000000000..5ef30fc0ad
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpProxyResource.java
@@ -0,0 +1,37 @@
+/*
+ * 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.platform.http.proxy.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+@Path("/platform-http-proxy")
+public class PlatformHttpProxyResource {
+
+    @ConfigProperty(name = "platform.origin.url")
+    String url;
+
+    @GET
+    public String getUrl() {
+        return url;
+    }
+
+}
diff --git 
a/integration-tests/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/Routes.java
 
b/integration-tests/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/Routes.java
new file mode 100644
index 0000000000..310f1948ad
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/main/java/org/apache/camel/quarkus/component/platform/http/proxy/it/Routes.java
@@ -0,0 +1,34 @@
+/*
+ * 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.platform.http.proxy.it;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+@ApplicationScoped
+public class Routes extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+
+        from("platform-http:proxy")
+                .log("header is :: ${headers.CamelHttpHost}")
+                .toD("http://${headers."; + Exchange.HTTP_HOST + 
"}?bridgeEndpoint=true");
+    }
+}
diff --git 
a/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpTestResource.java
 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpTestResource.java
new file mode 100644
index 0000000000..5fe00b73f4
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/PlatformHttpTestResource.java
@@ -0,0 +1,47 @@
+/*
+ * 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.platform.http.proxy.it;
+
+import java.util.Map;
+
+import 
org.apache.camel.quarkus.test.wiremock.WireMockTestResourceLifecycleManager;
+
+public class PlatformHttpTestResource extends 
WireMockTestResourceLifecycleManager {
+
+    private static final String PLATFORM_ORIGIN_HOST = "PLATFORM_ORIGIN_HOST";
+    private static final String PLATFORM_ORIGIN_PORT = "PLATFORM_ORIGIN_PORT";
+
+    @Override
+    protected String getRecordTargetBaseUrl() {
+        return "/";
+    }
+
+    @Override
+    protected boolean isMockingEnabled() {
+        return !envVarsPresent(PLATFORM_ORIGIN_HOST, PLATFORM_ORIGIN_PORT);
+    }
+
+    @Override
+    public Map<String, String> start() {
+        Map<String, String> options = super.start();
+        if (options.containsKey("wiremock.url")) {
+            String wiremockUrl = options.get("wiremock.url");
+            options.put("platform.origin.url", wiremockUrl);
+        }
+        return options;
+    }
+}
diff --git 
a/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTest.java
 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTest.java
new file mode 100644
index 0000000000..96f0148fad
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.platform.http.proxy.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(PlatformHttpTestResource.class)
+public class ProxyTest {
+    @Test
+    void testProxy() {
+
+        final var proxyUrl = "http://localhost:"; + RestAssured.port;
+        System.out.println("proxyUrl :: " + proxyUrl);
+
+        String url = given()
+                .get("/platform-http-proxy")
+                .body().asString();
+
+        System.out.println("URL is :: " + url);
+        given()
+                .proxy(proxyUrl)
+                .contentType(ContentType.JSON)
+                .when().get(url)
+                .then()
+                .statusCode(200)
+                .body(equalTo("{\"message\": \"Hello World!\"}"));
+
+        given()
+                .body("hello")
+                .proxy(proxyUrl)
+                .contentType(ContentType.JSON)
+                .when().post(url)
+                .then()
+                .statusCode(200)
+                .body(equalTo("{\"message\": \"Hello World!\"}"));
+    }
+
+}
diff --git 
a/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTestIT.java
 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTestIT.java
new file mode 100644
index 0000000000..c3a172647c
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/test/java/org/apache/camel/quarkus/component/platform/http/proxy/it/ProxyTestIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.platform.http.proxy.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+public class ProxyTestIT extends ProxyTest {
+}
diff --git 
a/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_GET.json
 
b/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_GET.json
new file mode 100644
index 0000000000..4552e75883
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_GET.json
@@ -0,0 +1,18 @@
+{
+  "id": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "name": "platform-http-proxy_api",
+  "request": {
+    "url": "/",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "body": "{\"message\": \"Hello World!\"}",
+    "headers": {
+      "Content-Type": "application/json; charset=UTF-8"
+    }
+  },
+  "uuid": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git 
a/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_POST.json
 
b/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_POST.json
new file mode 100644
index 0000000000..dcfce92e74
--- /dev/null
+++ 
b/integration-tests/platform-http-proxy/src/test/resources/mappings/originServer_POST.json
@@ -0,0 +1,18 @@
+{
+  "id": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "name": "platform-http-proxy_api",
+  "request": {
+    "url": "/",
+    "method": "POST"
+  },
+  "response": {
+    "status": 200,
+    "body": "{\"message\": \"Hello World!\"}",
+    "headers": {
+      "Content-Type": "application/json; charset=UTF-8"
+    }
+  },
+  "uuid": "09aa79df-8a19-41df-8655-e414d390d6ed",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index cdda0dcaff..99b39bf01e 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -170,6 +170,8 @@
         <module>pg-replication-slot</module>
         <module>pgevent</module>
         <module>platform-http</module>
+        <module>platform-http-proxy</module>
+        <module>platform-http-proxy-ssl</module>
         <module>protobuf</module>
         <module>pubnub</module>
         <module>quartz</module>
diff --git a/tooling/scripts/test-categories.yaml 
b/tooling/scripts/test-categories.yaml
index 5ab72b46ca..26e16bee0f 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -163,6 +163,8 @@ group-10:
   - mail
   - main-unknown-args-fail
   - main-unknown-args-ignore
+  - platform-http-proxy
+  - platform-http-proxy-ssl
 group-11:
   - compression-grouped
   - disruptor


Reply via email to