You will need to edit FileSystemView to handle user home directory. I changed 
mine to be similar to Apache FtpServer's implementation and contain a directory 
jail.

For testing mine, I use the SSHTools (j2ssh) library.

-----Original Message-----
From: Michael Coxon [mailto:[email protected]] 
Sent: Monday, August 06, 2012 9:27 PM
To: [email protected]
Subject: Help making an sftp unit test

I have been looking through the documentation/tutorials and its not clear to me 
how to create a mock sftp server so that I can test my jsch-based code. I'm 
probably missing something really obvious.

I have set up a test server, following the instructions with:


@Before
public void beforeTestSetup() {
    sshd = SshServer.setUpDefaultServer();
    sshd.setPort(22);
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));

    List<NamedFactory<UserAuth>> userAuthFactories = new 
ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthNone.Factory());
    sshd.setUserAuthFactories(userAuthFactories);
    sshd.setPublickeyAuthenticator(new PublickeyAuthenticator());


    sshd.setCommandFactory(new ScpCommandFactory());

    List<NamedFactory<Command>> namedFactoryList = new 
ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    try {
        sshd.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

But, I'm having trouble configuring it with an actual username, identity key 
and location to get and put files. I think the above will default to using a OS 
user's home directory (not ideal in my case as I would prefer using 
{project.dir}/test/resources).

The next thing is, do I need a client to connect to it, or it sufficient to 
just use some jsch code to connect?

Thanks,
Mike







________________________________
This email and any files transmitted with it may be confidential and are 
intended solely for the use of the individual or entity to whom they are 
addressed. This email may contain personal information of individuals, and be 
subject to Commonwealth and/or State privacy laws in Australia. This email is 
also subject to copyright. If you are not the intended recipient, you must not 
read, print, store, copy, forward or use this email for any reason, in 
accordance with privacy and copyright laws. If you have received this email in 
error, please notify the sender by return email, and delete this email from 
your inbox.

Reply via email to