Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Fake SFTP Server Rule is available from
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>fake-sftp-server-rule</artifactId>
<version>2.0.1</version>
<version>2.1.1</version>
</dependency>

If you upgrade from a version < 2.x to the newest version please read the last
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>fake-sftp-server-rule</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.1</version>
<packaging>jar</packaging>

<name>Fake SFTP Server Rule</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.stefanbirkner.fakesftpserver.rule;

import java.util.function.Consumer;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
Expand Down Expand Up @@ -182,6 +183,23 @@ public FileVisitResult postVisitDirectory(

private FileSystem fileSystem;
private SshServer server;
private Consumer<SshServer> sshServerConsumer = (sshServer) -> {};

/**
* Configures the internal SFTP server of the Apache SSHD project.
* If you need personal changes in internal SFTP server that
* are not supported by the rule, you can use this method to get the inner
* internal SFTP server of the rule before construction and change it to
* suit your needs.
* (Correct use of this feature is the responsibility of the user)
*
* @param sshServerConsumer internal SFTP server consumer
* @return the rule itself.
*/
public FakeSftpServerRule configureInternalSshServer(Consumer<SshServer> sshServerConsumer) {
this.sshServerConsumer = sshServerConsumer;
return this;
}

/**
* Returns the port of the SFTP server. If the SFTP server listens on an
Expand Down Expand Up @@ -435,6 +453,7 @@ private SshServer startServer(
* have to use a file system wrapper whose close() does nothing.
*/
server.setFileSystemFactory(session -> new DoNotClose(fileSystem));
sshServerConsumer.accept(server);
server.start();
this.server = server;
return server;
Expand Down