You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ji...@apache.org on 2025/02/18 11:31:02 UTC

(camel-quarkus) 02/03: fixes #6941: fixed load of ssh keyProvider from test resources

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

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

commit acbeadc8e784a99a60b665926636c5da8d1dfa16
Author: Jiri Ondrusek <on...@gmail.com>
AuthorDate: Mon Jan 27 12:49:05 2025 +0100

    fixes #6941: fixed load of ssh keyProvider from test resources
---
 .../camel/quarkus/component/ssh/it/SshTestResource.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

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
index 186d1eb434..cc939126b1 100644
--- 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
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.quarkus.component.ssh.it;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.LinkedList;
 import java.util.List;
@@ -79,8 +83,16 @@ public class SshTestResource implements QuarkusTestResourceLifecycleManager {
 
             sshd = SshServer.setUpDefaultServer();
             sshd.setPort(edPort);
-            sshd.setKeyPairProvider(new FileKeyPairProvider(
-                    Paths.get(Thread.currentThread().getContextClassLoader().getResource("edDSA/key_ed25519.pem").toURI())));
+
+            File tmpFile = File.createTempFile("key_ed25519-", ".pem");
+            try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("edDSA/key_ed25519.pem")) {
+                Files.write(tmpFile.toPath(), in.readAllBytes());
+                sshd.setKeyPairProvider(new FileKeyPairProvider(tmpFile.toPath()));
+            } catch (NullPointerException | IOException e) {
+                String message = "An issue occurred while loading key: edDSA/key_ed25519.pem";
+                throw new RuntimeException(message, e);
+            }
+
             sshd.setCommandFactory(new TestEchoCommandFactory());
             sshd.setPasswordAuthenticator((username, password, session) -> true);
             sshd.setPublickeyAuthenticator((username, key, session) -> true);