You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/09/18 15:21:47 UTC
[camel-quarkus] branch master updated: feat(ssh): promoting native
extension
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new dc0ff72 feat(ssh): promoting native extension
dc0ff72 is described below
commit dc0ff72dea92e5571a78e0de793e50a80e6d57a9
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Sep 10 15:39:56 2020 +0200
feat(ssh): promoting native extension
Closes #798
---
.../ROOT/pages/reference/components/ssh.adoc | 6 +-
.../ROOT/pages/reference/extensions/ssh.adoc | 8 +-
extensions-jvm/pom.xml | 1 -
.../component/ssh/deployment/SshProcessor.java | 46 ------------
.../quarkus/component/ssh/it/SshResource.java | 51 -------------
.../deployment/BouncycastleSupportProcessor.java | 15 ++++
.../main/resources/META-INF/quarkus-extension.yaml | 3 +-
extensions/pom.xml | 1 +
.../ssh/deployment/pom.xml | 4 +
.../component/ssh/deployment/SshProcessor.java | 87 ++++++++++++++++++++++
{extensions-jvm => extensions}/ssh/pom.xml | 1 -
{extensions-jvm => extensions}/ssh/runtime/pom.xml | 10 +++
.../ssh/runtime/SubstituteSecurityUtils.java | 65 ++++++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 3 +-
integration-tests/pom.xml | 1 +
.../ssh}/pom.xml | 38 +++++++++-
.../quarkus/component/ssh/it/SshResource.java | 82 ++++++++++++++++++++
.../camel/quarkus/component/ssh/it/SshIT.java | 16 +---
.../camel/quarkus/component/ssh/it/SshTest.java | 27 ++++++-
.../quarkus/component/ssh/it/SshTestResource.java | 77 +++++++++++++++++++
tooling/scripts/test-categories.yaml | 1 +
21 files changed, 414 insertions(+), 129 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/components/ssh.adoc b/docs/modules/ROOT/pages/reference/components/ssh.adoc
index 5350590..806bb61 100644
--- a/docs/modules/ROOT/pages/reference/components/ssh.adoc
+++ b/docs/modules/ROOT/pages/reference/components/ssh.adoc
@@ -4,11 +4,11 @@
= SSH
:cq-artifact-id: camel-quarkus-ssh
:cq-artifact-id-base: ssh
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
:cq-camel-part-name: ssh
:cq-camel-part-title: SSH
:cq-camel-part-description: Execute commands on remote hosts using SSH.
diff --git a/docs/modules/ROOT/pages/reference/extensions/ssh.adoc b/docs/modules/ROOT/pages/reference/extensions/ssh.adoc
index f39de94..6f10b1b 100644
--- a/docs/modules/ROOT/pages/reference/extensions/ssh.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/ssh.adoc
@@ -3,15 +3,15 @@
= SSH
:cq-artifact-id: camel-quarkus-ssh
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-description: Execute commands on remote hosts using SSH.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##
Execute commands on remote hosts using SSH.
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 676bd5c..5d75745 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -132,7 +132,6 @@
<module>soroush</module>
<module>splunk</module>
<module>splunk-hec</module>
- <module>ssh</module>
<module>stax</module>
<module>stomp</module>
<module>stringtemplate</module>
diff --git a/extensions-jvm/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java b/extensions-jvm/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java
deleted file mode 100644
index baccfa3..0000000
--- a/extensions-jvm/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java
+++ /dev/null
@@ -1,46 +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.ssh.deployment;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
-
-class SshProcessor {
-
- private static final Logger LOG = Logger.getLogger(SshProcessor.class);
- private static final String FEATURE = "camel-ssh";
-
- @BuildStep
- FeatureBuildItem feature() {
- return new FeatureBuildItem(FEATURE);
- }
-
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
- }
-}
diff --git a/extensions-jvm/ssh/integration-test/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java b/extensions-jvm/ssh/integration-test/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java
deleted file mode 100644
index e64c138..0000000
--- a/extensions-jvm/ssh/integration-test/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java
+++ /dev/null
@@ -1,51 +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.ssh.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/ssh")
-@ApplicationScoped
-public class SshResource {
-
- private static final Logger LOG = Logger.getLogger(SshResource.class);
-
- private static final String COMPONENT_SSH = "ssh";
- @Inject
- CamelContext context;
-
- @Path("/load/component/ssh")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentSsh() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_SSH) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_SSH);
- return Response.status(500, COMPONENT_SSH + " could not be loaded from the Camel context").build();
- }
-}
diff --git a/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java b/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java
index 47dfbac..c940eeb 100644
--- a/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java
+++ b/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java
@@ -16,11 +16,15 @@
*/
package org.apache.camel.quarkus.support.bouncycastle.deployment;
+import java.util.Arrays;
+
+import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import org.jboss.jandex.IndexView;
public class BouncycastleSupportProcessor {
@@ -51,4 +55,15 @@ public class BouncycastleSupportProcessor {
IndexDependencyBuildItem registerBCDependencyForIndex() {
return new IndexDependencyBuildItem("org.bouncycastle", "bcprov-jdk15on");
}
+
+ @BuildStep
+ void secureRandomConfiguration(BuildProducer<RuntimeReinitializedClassBuildItem> reinitialized) {
+ for (String s : Arrays.asList(
+ "java.security.SecureRandom",
+ "org.bouncycastle.crypto.CryptoServicesRegistrar",
+ "org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV",
+ "org.bouncycastle.jcajce.provider.drbg.DRBG$Default")) {
+ reinitialized.produce(new RuntimeReinitializedClassBuildItem(s));
+ }
+ }
}
diff --git a/extensions/browse/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/browse/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index a92b325..5e702e2 100644
--- a/extensions/browse/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/browse/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
name: "Camel Browse"
description: "Inspect the messages received on endpoints supporting BrowsableEndpoint"
metadata:
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/browse.html"
categories:
- "integration"
status:
- - "preview"
+ - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index b4ed78e..29c5334 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -175,6 +175,7 @@
<module>snakeyaml</module>
<module>soap</module>
<module>sql</module>
+ <module>ssh</module>
<module>stream</module>
<module>tagsoup</module>
<module>tarfile</module>
diff --git a/extensions-jvm/ssh/deployment/pom.xml b/extensions/ssh/deployment/pom.xml
similarity index 93%
rename from extensions-jvm/ssh/deployment/pom.xml
rename to extensions/ssh/deployment/pom.xml
index 0e07eed..066948b 100644
--- a/extensions-jvm/ssh/deployment/pom.xml
+++ b/extensions/ssh/deployment/pom.xml
@@ -40,6 +40,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ssh</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle-deployment</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java b/extensions/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java
new file mode 100644
index 0000000..4b2b9df
--- /dev/null
+++ b/extensions/ssh/deployment/src/main/java/org/apache/camel/quarkus/component/ssh/deployment/SshProcessor.java
@@ -0,0 +1,87 @@
+/*
+ * 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.ssh.deployment;
+
+import java.security.KeyFactory;
+import java.security.KeyPairGenerator;
+import java.security.Signature;
+import java.util.Arrays;
+
+import javax.crypto.KeyAgreement;
+import javax.crypto.Mac;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.apache.sshd.common.channel.ChannelListener;
+import org.apache.sshd.common.forward.PortForwardingEventListener;
+import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
+import org.apache.sshd.common.session.SessionListener;
+import org.apache.sshd.common.util.security.eddsa.EdDSASecurityProviderUtils;
+
+class SshProcessor {
+
+ private static final String FEATURE = "camel-ssh";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ RuntimeInitializedClassBuildItem delayEdDSAConfiguration() {
+ return new RuntimeInitializedClassBuildItem(EdDSASecurityProviderUtils.class.getName());
+ }
+
+ @BuildStep
+ void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
+ reflectiveClasses.produce(
+ new ReflectiveClassBuildItem(
+ true,
+ false,
+ KeyPairGenerator.class,
+ KeyAgreement.class,
+ KeyFactory.class,
+ Signature.class,
+ Mac.class));
+ reflectiveClasses.produce(
+ new ReflectiveClassBuildItem(
+ false,
+ false,
+ Nio2ServiceFactoryFactory.class));
+ }
+
+ @BuildStep
+ NativeImageResourceBuildItem nativeImageResourceBuildItem() {
+ return new NativeImageResourceBuildItem("META-INF/services/org.apache.sshd.common.io.IoServiceFactoryFactory");
+ }
+
+ @BuildStep
+ void sessionProxy(BuildProducer<NativeImageProxyDefinitionBuildItem> proxiesProducer) {
+ for (String s : Arrays.asList(
+ SessionListener.class.getName(),
+ ChannelListener.class.getName(),
+ PortForwardingEventListener.class.getName())) {
+ proxiesProducer.produce(new NativeImageProxyDefinitionBuildItem(s));
+ }
+ }
+
+}
diff --git a/extensions-jvm/ssh/pom.xml b/extensions/ssh/pom.xml
similarity index 97%
rename from extensions-jvm/ssh/pom.xml
rename to extensions/ssh/pom.xml
index 9acb71d..052826e 100644
--- a/extensions-jvm/ssh/pom.xml
+++ b/extensions/ssh/pom.xml
@@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/ssh/runtime/pom.xml b/extensions/ssh/runtime/pom.xml
similarity index 89%
rename from extensions-jvm/ssh/runtime/pom.xml
rename to extensions/ssh/runtime/pom.xml
index d14edaf..7702c3e 100644
--- a/extensions-jvm/ssh/runtime/pom.xml
+++ b/extensions/ssh/runtime/pom.xml
@@ -34,6 +34,7 @@
<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
</properties>
<dependencyManagement>
@@ -57,6 +58,15 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-ssh</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.graalvm.nativeimage</groupId>
+ <artifactId>svm</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions/ssh/runtime/src/main/java/org/apache/camel/quarkus/component/ssh/runtime/SubstituteSecurityUtils.java b/extensions/ssh/runtime/src/main/java/org/apache/camel/quarkus/component/ssh/runtime/SubstituteSecurityUtils.java
new file mode 100644
index 0000000..2bca5bc
--- /dev/null
+++ b/extensions/ssh/runtime/src/main/java/org/apache/camel/quarkus/component/ssh/runtime/SubstituteSecurityUtils.java
@@ -0,0 +1,65 @@
+/*
+ * 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.ssh.runtime;
+
+import java.security.GeneralSecurityException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.security.SecurityUtils;
+
+/**
+ * We're substituting those offending methods that would require the presence of
+ * net.i2p.crypto:eddsa library which is not supported by Camel SSH component
+ */
+@TargetClass(SecurityUtils.class)
+final class SubstituteSecurityUtils {
+
+ @Substitute
+ public static boolean compareEDDSAPPublicKeys(PublicKey k1, PublicKey k2) {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+ @Substitute
+ public static boolean compareEDDSAPrivateKeys(PrivateKey k1, PrivateKey k2) {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+ @Substitute
+ public static PublicKey generateEDDSAPublicKey(String keyType, byte[] seed) throws GeneralSecurityException {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+ @Substitute
+ public static org.apache.sshd.common.signature.Signature getEDDSASigner() {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+ @Substitute
+ public static <B extends Buffer> B putRawEDDSAPublicKey(B buffer, PublicKey key) {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+ @Substitute
+ public static PublicKey recoverEDDSAPublicKey(PrivateKey key) throws GeneralSecurityException {
+ throw new UnsupportedOperationException("EdDSA Signer not available");
+ }
+
+}
diff --git a/extensions-jvm/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from extensions-jvm/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index fe5b03b..279bbf5 100644
--- a/extensions-jvm/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/ssh/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
name: "Camel SSH"
description: "Execute commands on remote hosts using SSH"
metadata:
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/ssh.html"
categories:
- "integration"
status:
- - "preview"
+ - "stable"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 62087d0..4066598 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -144,6 +144,7 @@
<module>smallrye-reactive-messaging</module>
<module>soap</module>
<module>sql</module>
+ <module>ssh</module>
<module>tarfile</module>
<module>telegram</module>
<module>tika</module>
diff --git a/extensions-jvm/ssh/integration-test/pom.xml b/integration-tests/ssh/pom.xml
similarity index 73%
rename from extensions-jvm/ssh/integration-test/pom.xml
rename to integration-tests/ssh/pom.xml
index f992666..658e772 100644
--- a/extensions-jvm/ssh/integration-test/pom.xml
+++ b/integration-tests/ssh/pom.xml
@@ -23,9 +23,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>
<artifactId>camel-quarkus-ssh-integration-test</artifactId>
@@ -65,6 +64,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- 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>
@@ -97,4 +101,34 @@
</plugin>
</plugins>
</build>
+
+ <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>
+ </profiles>
</project>
diff --git a/integration-tests/ssh/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java b/integration-tests/ssh/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java
new file mode 100644
index 0000000..0cf5ebc
--- /dev/null
+++ b/integration-tests/ssh/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java
@@ -0,0 +1,82 @@
+/*
+ * 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.ssh.it;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ProducerTemplate;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/ssh")
+@ApplicationScoped
+public class SshResource {
+
+ private final String user = "test";
+ private final String password = "password";
+
+ @ConfigProperty(name = "quarkus.ssh.host")
+ private String host;
+ @ConfigProperty(name = "quarkus.ssh.port")
+ private String port;
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @POST
+ @Path("/file/{fileName}")
+ @Consumes(MediaType.TEXT_PLAIN)
+ public Response writeToFile(@PathParam("fileName") String fileName, String content)
+ throws URISyntaxException {
+
+ String sshWriteFileCommand = String.format("printf \"%s\" > %s", content, fileName);
+ producerTemplate.sendBody(
+ String.format("ssh:%s:%s?username=%s&password=%s", host, port, user, password),
+ sshWriteFileCommand);
+
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .build();
+ }
+
+ @GET
+ @Path("/file/{fileName}")
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response readFile(@PathParam("fileName") String fileName) throws URISyntaxException {
+
+ String sshReadFileCommand = String.format("cat %s", fileName);
+ String content = producerTemplate.requestBody(
+ String.format("ssh:%s:%s?username=%s&password=%s", host, port, user, password),
+ sshReadFileCommand,
+ String.class);
+
+ return Response
+ .ok(content)
+ .build();
+ }
+}
diff --git a/extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshIT.java
similarity index 71%
copy from extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
copy to integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshIT.java
index d419f4e..c18d67b 100644
--- a/extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
+++ b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshIT.java
@@ -16,19 +16,9 @@
*/
package org.apache.camel.quarkus.component.ssh.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
-@QuarkusTest
-class SshTest {
-
- @Test
- public void loadComponentSsh() {
- /* A simple autogenerated test */
- RestAssured.get("/ssh/load/component/ssh")
- .then()
- .statusCode(200);
- }
+@NativeImageTest
+class SshIT extends SshTest {
}
diff --git a/extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
similarity index 54%
rename from extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
rename to integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
index d419f4e..4681ee0 100644
--- a/extensions-jvm/ssh/integration-test/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
+++ b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java
@@ -16,19 +16,38 @@
*/
package org.apache.camel.quarkus.component.ssh.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 org.junit.jupiter.api.Assertions.assertEquals;
+
@QuarkusTest
+@QuarkusTestResource(SshTestResource.class)
class SshTest {
@Test
- public void loadComponentSsh() {
- /* A simple autogenerated test */
- RestAssured.get("/ssh/load/component/ssh")
+ public void testWriteToSSHAndReadFromSSH() {
+ final String fileContent = "Hello Camel Quarkus SSH";
+ // Write a file to SSH session
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(fileContent)
+ .post("/ssh/file/camelTest")
+ .then()
+ .statusCode(201);
+
+ // Retrieve a file from SSH session
+ String sshFileContent = RestAssured.get("/ssh/file/camelTest")
.then()
- .statusCode(200);
+ .contentType(ContentType.TEXT)
+ .statusCode(200)
+ .extract()
+ .body().asString();
+
+ assertEquals(fileContent, sshFileContent);
}
}
diff --git a/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java
new file mode 100644
index 0000000..df33da3
--- /dev/null
+++ b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.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.ssh.it;
+
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.utility.TestcontainersConfiguration;
+
+public class SshTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SshTestResource.class);
+
+ private static final int SSH_PORT = 2222;
+ private static final String SSH_IMAGE = "linuxserver/openssh-server";
+
+ private GenericContainer container;
+
+ @Override
+ public Map<String, String> start() {
+ LOGGER.info(TestcontainersConfiguration.getInstance().toString());
+ LOGGER.info("Starting SSH container");
+
+ try {
+ container = new GenericContainer(SSH_IMAGE)
+ .withExposedPorts(SSH_PORT)
+ .withEnv("PASSWORD_ACCESS", "true")
+ .withEnv("USER_NAME", "test")
+ .withEnv("USER_PASSWORD", "password")
+ .waitingFor(Wait.forListeningPort());
+
+ container.start();
+
+ LOGGER.info("Started SSH container to {}:{}", container.getContainerIpAddress(),
+ container.getMappedPort(SSH_PORT).toString());
+
+ return CollectionHelper.mapOf(
+ "quarkus.ssh.host",
+ container.getContainerIpAddress(),
+ "quarkus.ssh.port",
+ container.getMappedPort(SSH_PORT).toString());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void stop() {
+ LOGGER.info("Stopping SSH container");
+
+ try {
+ if (container != null) {
+ container.stop();
+ }
+ } catch (Exception e) {
+ // ignored
+ }
+ }
+}
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 5c35259..7e1ec77 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -114,6 +114,7 @@ networking2-dataformats:
- flatpack
- grok
- tarfile
+ - ssh
platform:
- microprofile
- openapi-java