stefanbirkner / fake-sftp-server-lambda Goto Github PK
View Code? Open in Web Editor NEWRuns an in-memory SFTP server while your tests are running.
License: MIT License
Runs an in-memory SFTP server while your tests are running.
License: MIT License
At some point within the last month our tests started failing without any code change. Does anyone know where to start troubleshooting following issue?
[ main] c.s.gcssftpadapter.service.SftpWriter : Trying to create file <stuff> in dir </testing/stuff> on server <localhost>
[ main] o.s.i.s.s.DefaultSftpSessionFactory : The authenticity of host 'localhost' can't be established.
RSA key fingerprint is 6a:da:7f:02:81:62:3b:d4:1d:27:85:e1:20:9d:d1:36.
Are you sure you want to continue connecting?
[ main] com.jcraft.jsch : Permanently added 'localhost' (RSA) to the list of known hosts.
[)-nio2-thread-5] o.a.s.server.session.ServerSessionImpl : Session testing@/127.0.0.1:55002 authenticated
[)-nio2-thread-2] o.a.s.server.session.ServerSessionImpl : exceptionCaught(ServerSessionImpl[testing@/127.0.0.1:55002])[state=Opened] RuntimeSshException: null
[)-nio2-thread-2] o.a.s.server.session.ServerSessionImpl : exceptionCaught(ServerSessionImpl[testing@/127.0.0.1:55002])[state=Opened] caused by AbstractMethodError: Receiver class com.github.stefanbirkner.fakesftpserver.lambda.FakeSftpServer$$Lambda$1219/0x0000000800ba5440 does not define or inherit an implementation of the resolved method 'abstract java.nio.file.FileSystem createFileSystem(org.apache.sshd.common.session.SessionContext)' of interface org.apache.sshd.common.file.FileSystemFactory.
java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
Using com.github.stefanbirkner.fake-sftp-server-lambda:1.0.0
, com.jcraft.jsch:0.1.55
The library doesn't work with sshd-sftp 2.5:
16:54:51.029 [warn] - [SessionHelper.java:1172] - exceptionCaught(ServerSessionImpl[ssh-user@/127.0.0.1:35184])[state=Opened] RuntimeSshException: null
16:54:51.029 [warn] - [SessionHelper.java:1179] - exceptionCaught(ServerSessionImpl[ssh-user@/127.0.0.1:35184])[state=Opened] caused by AbstractMethodError: Receiver class com.github.stefanbirkner.fakesftpserver.lambda.FakeSftpServer$$Lambda$12324/0x00000008036c1440 does not define or inherit an implementation of the resolved method abstract createFileSystem(Lorg/apache/sshd/common/session/SessionContext;)Ljava/nio/file/FileSystem; of interface org.apache.sshd.common.file.FileSystemFactory.
In general, the dependency range (any version >= 2) is too loose. Clearly breaking changes are happening to the dependency and such a loose dependency version shunts the work of having to find a compatible version onto the user.
sshd-sftp:2.9.0 was recently released and the fake-sftp-server stopped working.
Pinning the sshd-sftp to 2.8.0 fixes the problem.
Thank you for the useful library!
I get
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project jfr-srv-batch: Could not resolve dependencies for project com.edb.fs.tac.jfr.srv:jfr-srv-batch:jar:8.0.3-SNAPSHOT: Failed to collect dependencies at com.github.stefanbirkner:fake-sftp-server-lambda:jar:1.0.0 -> com.github.marschall:memoryfilesystem:jar:[0.8.0,)
would it be netter to just depend on a fixed version instead of using ranges?
hello @stefanbirkner
First of all thank you for this lib we've been using for a few years !
are you accepting contribution (mainly dependencies upgrades) ?
are you willing to make a new release based on those PRs ?
I've got a couple of detailed test cases where we do multiple sftp related calls. They look very odd when I have to wrap all of the test rows inside the withSftpServer lambda. It would be much more preferable if start and stop of the server was independent of each other.
Running the following test in local machine runs fine but not on github actions (linux java 11) kotlin project
I get
java.lang.IllegalStateException at withSftpServer
Caused by: java.net.SocketException at withSftpServer
Code:
@SpringBootTest
@DirtiesContext
class SFTPClient {
@Test
@Throws(Exception::class)
fun test() {
withSftpServer { server ->
server.setPort(22)
server.addUser("username","")
server.createDirectory("myDir")
}
}
}
I need to test code that generates file names and writes out the files. How can I get the contents of a directory?
Hi,
With the given package I am unable to start the SFTP server on Ubuntu system.
I am seeing server port up message. But actually server is not getting up
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
The server is started on the port 40745
My code is as bellow. The server is creating properly and i can put files as well. But when i try to connect to server using jsch, it always gives "Auth fail" in session.connect()
withSftpServer(server -> {
server.addUser("username", "password1").setPort(1234);
JSch jsch = new JSch();
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
final int rPort = Integer.parseInt("22");
String knownHostPublicKey = "127.0.0.1" + " ssh-rsa " + <<HOST-KEY>>;
jsch.setKnownHosts(new ByteArrayInputStream(knownHostPublicKey.getBytes()));
session = jsch.getSession("username", "127.0.0.1", rPort);
session.setPassword("password1");
session.setTimeout(25000);
session.connect(25000); **//Auth fail here**
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.