GH-171 Fix SFTP Supplier

Related to: https://github.com/spring-cloud/stream-applications/issues/171

It might not be necessary in real world, but with `SshServer` we fail
when we disconnect the session and cannot connect it back because
that server decides to die for a strange reason like no connections.

* Upgrade to SSHD 2.7.0
* Wrap default SFTP SF into a `CachingSessionFactory` to keep sessions opened
and don't let the server to die because on connections from clients
* Reenable SFTP Supplier tests
This commit is contained in:
Artem Bilan
2021-06-08 16:27:33 -04:00
parent 2c2abf26f8
commit e3775e4c1a
4 changed files with 7 additions and 10 deletions

View File

@@ -14,7 +14,7 @@
<description>file consumer</description>
<properties>
<sshd-core.version>1.6.0</sshd-core.version>
<sshd-sftp.version>2.7.0</sshd-sftp.version>
<apache-ftpserver.version>1.1.1</apache-ftpserver.version>
<awaitility.version>4.0.3</awaitility.version>
</properties>
@@ -47,8 +47,8 @@
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>${sshd-core.version}</version>
<artifactId>sshd-sftp</artifactId>
<version>${sshd-sftp.version}</version>
</dependency>
<dependency>

View File

@@ -29,7 +29,7 @@ import java.util.Collections;
import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
import org.apache.sshd.sftp.server.SftpSubsystemFactory;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -62,7 +62,7 @@ public class SftpTestSupport extends RemoteFileTestSupport {
StringUtils.hasText(password) && !"badPassword".equals(password)); // fail if pub key validation failed
server.setPublickeyAuthenticator((username, key, session) -> key.equals(decodePublicKey("id_rsa_pp.pub")));
server.setPort(0);
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
server.setFileSystemFactory(new VirtualFileSystemFactory(remoteTemporaryFolder));
server.start();