Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-19 Thread via GitHub


jamesnetherton merged PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#issuecomment-2598553992

   I had to exclude from licencing plugin `knowh_hosts` file 
`**/known_hosts`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1920317378


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1920316933


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   removed



##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+

Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1920316183


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   removed



##
integration-tests/ssh/pom.xml:
##
@@ -98,6 +115,48 @@
 
 
 
+
+non-fips
+
+
+!fips
+
+
+
+
+
+org.codehaus.mojo
+exec-maven-plugin
+
+
+generate-certs.sh
+generate-sources
+
+exec
+
+
+bash
+
+
${basedir}/generate-certs.sh

Review Comment:
   done



##
integration-tests/ssh/pom.xml:
##
@@ -51,6 +59,11 @@
 rest-assured
 test
 
+
+org.assertj
+assertj-core

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1920315832


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));

Review Comment:
   I moved test resources into `src/test/resources` and I'm loading them via 
classpath



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-17 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1920252548


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)

Review Comment:
   Reported as https://github.com/apache/camel-quarkus/issues/6917



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919666767


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   I copied the code from camel, but the sleep seems unnecessary, I'll check 
that



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919666919


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   I copied the code from camel, but the sleep seems unnecesary, I'll check that



##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+s

Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919666919


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   I copied the code from camel, but the sleep seems not necessary, I'll check 
that



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919668664


##
integration-tests/ssh/pom.xml:
##
@@ -51,6 +59,11 @@
 rest-assured
 test
 
+
+org.assertj
+assertj-core

Review Comment:
   I think I used the assertion for asserj-core , but surely not necessary



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919667695


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));

Review Comment:
   I'll fix that, thanks for noticing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919666767


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   I copyed the code from camel, but the sleep seems unnecessay, I'll check that



##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+s

Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


JiriOndrusek commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1919666351


##
integration-tests/ssh/pom.xml:
##
@@ -98,6 +115,48 @@
 
 
 
+
+non-fips
+
+
+!fips
+
+
+
+
+
+org.codehaus.mojo
+exec-maven-plugin
+
+
+generate-certs.sh
+generate-sources
+
+exec
+
+
+bash
+
+
${basedir}/generate-certs.sh

Review Comment:
   sounds nice , this was plan B for me



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


jamesnetherton commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918645327


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));

Review Comment:
   I think it'd need to be read from the classpath and copied to the filesystem 
for it to work in the platform.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


jamesnetherton commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918616192


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {

Review Comment:
   ```suggestion
   sshds.forEach(s -> {
   ```



##
integration-tests/ssh/pom.xml:
##
@@ -51,6 +59,11 @@
 rest-assured
 test
 
+
+org.assertj
+assertj-core

Review Comment:
   Do we need this?



##
integration-tests/ssh/pom.xml:
##
@@ -98,6 +115,48 @@
 
 
 
+
+non-fips
+
+
+!fips
+
+
+
+
+
+org.codehaus.mojo
+exec-maven-plugin
+
+
+generate-certs.sh
+generate-sources
+
+exec
+
+
+bash
+
+
${basedir}/generate-certs.sh

Review Comment:
   > generation script requires open-ssh -> if it would be a problem for CLI, 
I'll switch from automatic generation to storing generated certificates into 
github
   
   For now, I think we should just commit the certs, remove this 
`exec-maven-plugin` execution and keep the script so that certs can be 
regenerated manually if needed. The README note about the script / FIPS profile 
could also be removed.
   
   Might be worth opening a follow up issue to see if we can somehow get t

Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


aldettinger commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918602872


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)
+protected String getHostKey() {
+//todo test
+//return "target/classes/hostkey.pem";
+return "target/certs/user01.key";
+}
+
 @Override
 public void stop() {
-LOGGER.info("Stopping SSH container");
+LOGGER.info("Stopping SSH container and servers");
 
 try {
 if (container != null) {
 container.stop();
 }
+sshds.stream().forEach(s -> {
+try {
+s.stop(true);
+Thread.sleep(50);

Review Comment:
   Why is the thread sleep needed please ? `s.stop(true)` should stop 
immediately ? like stop synchronously ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


aldettinger commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918598929


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+LOGGER.info("Started SSHD server to {}:{}", container.getHost(),
+securedPort);
+
+return Map.of(
+"quarkus.ssh.host", "localhost",
+"quarkus.ssh.port", 
container.getMappedPort(SSH_PORT).toString(),
+"quarkus.ssh.secured-port", securedPort + "",
+"quarkus.ssh.ed-port", edPort + "",
+"ssh.username", USERNAME,
+"ssh.password", PASSWORD);
 } catch (Exception e) {
 throw new RuntimeException(e);
 }
 }
 
+//todo proper path (no target)

Review Comment:
   Probably, todo could be removed ? or follow up tickets opened ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


aldettinger commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918598117


##
integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTestResource.java:
##
@@ -45,33 +54,77 @@ public Map start() {
 container = new GenericContainer(SSH_IMAGE)
 .withExposedPorts(SSH_PORT)
 .withEnv("PASSWORD_ACCESS", "true")
-.withEnv("USER_NAME", "test")
-.withEnv("USER_PASSWORD", "password")
+.withEnv("USER_NAME", USERNAME)
+.withEnv("USER_PASSWORD", PASSWORD)
 .waitingFor(Wait.forListeningPort());
 
 container.start();
 
 LOGGER.info("Started SSH container to {}:{}", container.getHost(),
 container.getMappedPort(SSH_PORT).toString());
 
-return CollectionHelper.mapOf(
-"quarkus.ssh.host",
-container.getHost(),
-"quarkus.ssh.port",
-container.getMappedPort(SSH_PORT).toString());
+securedPort = AvailablePortFinder.getNextAvailable();
+
+var sshd = SshServer.setUpDefaultServer();
+sshd.setPort(securedPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get(getHostKey(;
+sshd.setCommandFactory(new TestEchoCommandFactory());
+sshd.setPasswordAuthenticator((username, password, session) -> 
true);
+sshd.setPublickeyAuthenticator((username, key, session) -> true);
+sshd.start();
+
+sshds.add(sshd);
+
+edPort = AvailablePortFinder.getNextAvailable();
+
+sshd = SshServer.setUpDefaultServer();
+sshd.setPort(edPort);
+sshd.setKeyPairProvider(new 
FileKeyPairProvider(Paths.get("target/classes/edDSA/key_ed25519.pem")));

Review Comment:
   Do we remind if such statements run on the quarkus platform ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] fixes #6909 ssh: extend test coverage [camel-quarkus]

2025-01-16 Thread via GitHub


aldettinger commented on code in PR #6912:
URL: https://github.com/apache/camel-quarkus/pull/6912#discussion_r1918588146


##
integration-tests/ssh/src/main/java/org/apache/camel/quarkus/component/ssh/it/SshResource.java:
##
@@ -69,13 +87,60 @@ public Response writeToFile(@PathParam("fileName") String 
fileName, String conte
 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 content = consumerTemplate.receiveBody(
+
String.format("ssh:%s:%s?username=%s&password=%s&pollCommand=%s", host, port, 
username, password,
+sshReadFileCommand),
 String.class);
 
 return Response
 .ok(content)
 .build();
 }
+
+@POST
+@Path("/send")
+@Consumes(MediaType.APPLICATION_JSON)
+public Map send(@QueryParam("command") String command,
+@QueryParam("component") @DefaultValue("ssh") String component,
+@QueryParam("serverType") @DefaultValue("userPassword") String 
serverType,
+@QueryParam("pathSuffix") String pathSuffix,
+Map headers)
+throws URISyntaxException {
+
+var p = switch (ServerType.valueOf(serverType)) {

Review Comment:
   Maybe this one could rename p -> port ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org