I havne’t got the far - I haven’t had that requirement in a test yet - sorry.
Please let me know what you find - I’d like to this JUnit Rule to be as helpful as possible. Eventually, I’ll see if the MINA project want’s it - but I think it needs a little more testing and polish before I offer it. > On Sep 8, 2016, at 3:13 PM, Goyal, Arpit <arpit.go...@sap.com> wrote: > > Hi Stevenson, > > I spent my Saturday figuring it out and turns out you have already done it. > > But if you have figured out Certificate based authentication of SFTP Routes > using MINA-SSHD, please put that to your GIT project as that is the next > thing I want to verify :) > > Regards, > Arpit. > > -----Original Message----- > From: Quinn Stevenson [mailto:qu...@pronoia-solutions.com > <mailto:qu...@pronoia-solutions.com>] > Sent: Thursday, September 8, 2016 12:46 PM > To: users@camel.apache.org <mailto:users@camel.apache.org> > Subject: Re: Unable to connect from camel-ftp to apache mina-sshd > > For what it’s worth, I’ve written a JUnit Resource that uses MINA-SSHD - I > use it quite a bit in my testing of SFTP routes. > https://github.com/hqstevenson/sftp-junit > <https://github.com/hqstevenson/sftp-junit> > <https://github.com/hqstevenson/sftp-junit > <https://github.com/hqstevenson/sftp-junit>> > > Unfortunately, I haven’t put any documentation or examples of using it with > the project, but if you’re interested, I can pull an example from one of my > tests to share. > >> On Sep 3, 2016, at 8:26 PM, Goyal, Arpit <arpit.go...@sap.com> wrote: >> >> Got this working :) <Phew> >> >> Not just camel-route mocking is awesome, with Apache Mina-SSHD, in-junit >> verification of SFTP endpoint configuration too :) >> >> Beer-cheer, >> Arpit. >> >> -----Original Message----- >> From: Goyal, Arpit [mailto:arpit.go...@sap.com] >> Sent: Friday, September 2, 2016 10:52 PM >> To: users@camel.apache.org >> Subject: Unable to connect from camel-ftp to apache mina-sshd >> >> Hi Colleagues, >> >> I am trying a very simple scenario where I am hosting apache mina-sshd as >> SFTP Server in my UNIT Test. Any one has idea why connection to SFTP always >> fails? >> >> Camel ftp - 2.16.3 >> Apache mina sshd - 1.2.0 >> >> Regards, >> Arpit. >> >> >> My Camel Route in test case >> ------------------------------------- >> from("direct:xxx").process("new >> MyProcessor()").to("sftp:localhost:9696?username=...&password=....&[options]") >> >> >> ERROR: >> ----------- >> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot >> connect to sftp://dummy@localhost:9696 >> at >> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146) >> at >> org.apache.camel.component.file.remote.RemoteFileProducer.connectIfNecessary(RemoteFileProducer.java:209) >> at >> org.apache.camel.component.file.remote.RemoteFileProducer.recoverableConnectIfNecessary(RemoteFileProducer.java:201) >> at >> org.apache.camel.component.file.remote.RemoteFileProducer.preWriteCheck(RemoteFileProducer.java:133) >> at >> org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:113) >> Caused by: com.jcraft.jsch.JSchException: failed to send channel request >> at com.jcraft.jsch.Request.write(Request.java:65) >> at com.jcraft.jsch.RequestSftp.request(RequestSftp.java:47) >> at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:237) >> at com.jcraft.jsch.Channel.connect(Channel.java:152) >> at >> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:130) >> ... 74 more >> >> Test case Parent class - all children start camel route as given above >> -------------------------------------------------------------------------------------- >> import java.io.File; >> import java.io.IOException; >> import java.util.Arrays; >> >> import org.apache.sshd.common.NamedFactory; >> import org.apache.sshd.common.file.virtualfs.NativeFileSystemFactory; >> import org.apache.sshd.server.Command; >> import org.apache.sshd.server.SshServer; >> import org.apache.sshd.server.auth.password.PasswordAuthenticator; >> import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; >> import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; >> import org.apache.sshd.server.scp.ScpCommandFactory; >> import org.apache.sshd.server.session.ServerSession; >> import org.apache.sshd.server.subsystem.sftp.SftpSubsystem; >> import org.testng.annotations.AfterClass; >> import org.testng.annotations.BeforeClass; >> >> public abstract class AbstractSftpServerTest { >> >> private static SshServer sftpServer; >> private static final String TEMP_FOLDER = >> System.getProperty("java.io.tmpdir"); >> private static File tempFolder; >> private static File tempFile; >> >> protected static final int PORT = 9696; >> >> @BeforeClass >> public static void beforeClass() throws IOException { >> sftpServer = SshServer.setUpDefaultServer(); >> sftpServer.setHost("localhost"); >> tempFolder = new File(TEMP_FOLDER); >> tempFile = File.createTempFile("server", ".key", tempFolder); >> sftpServer.setPort(PORT); >> sftpServer.setFileSystemFactory(new NativeFileSystemFactory ()); >> sftpServer.setCommandFactory(new ScpCommandFactory()); >> sftpServer.setKeyPairProvider(new >> SimpleGeneratorHostKeyProvider(tempFile)); >> >> sftpServer.setPasswordAuthenticator(new PasswordAuthenticator() { >> >> @Override >> public boolean authenticate(String username, String password, >> ServerSession session) throws PasswordChangeRequiredException { >> return true; >> } >> }); >> sftpServer.start(); >> } >> >> >> @AfterClass >> public void afterClass() throws IOException { >> sftpServer.stop(); >> tempFile.delete(); >> } >> }