Upgrade dependencies and fix tests for them

This commit is contained in:
Artem Bilan
2018-11-28 13:55:15 -05:00
committed by Gary Russell
parent 39fef2c70a
commit 9d21bf29f6
4 changed files with 33 additions and 32 deletions

View File

@@ -38,6 +38,8 @@ import com.jcraft.jsch.ChannelSftp.LsEntry;
*
* @author David Turanski
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3
*/
public class SftpTestSupport extends RemoteFileTestSupport {
@@ -59,7 +61,7 @@ public class SftpTestSupport extends RemoteFileTestSupport {
server = SshServer.setUpDefaultServer();
server.setPasswordAuthenticator((username, password, session) -> true);
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.getRoot().toPath()));
server.start();
@@ -73,15 +75,15 @@ public class SftpTestSupport extends RemoteFileTestSupport {
factory.setUser("foo");
factory.setPassword("foo");
factory.setAllowUnknownKeys(true);
return new CachingSessionFactory<LsEntry>(factory);
return new CachingSessionFactory<>(factory);
}
@AfterClass
public static void stopServer() throws Exception {
server.stop();
File hostkey = new File("hostkey.ser");
if (hostkey.exists()) {
hostkey.delete();
File hostKey = new File("hostkey.ser");
if (hostKey.exists()) {
hostKey.delete();
}
}

View File

@@ -32,10 +32,8 @@ import java.security.spec.RSAPublicKeySpec;
import java.util.Arrays;
import java.util.Collections;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.command.Command;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
import org.junit.Test;
@@ -65,8 +63,8 @@ public class SftpServerTests {
try {
server.setPasswordAuthenticator((arg0, arg1, arg2) -> true);
server.setPort(0);
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
server.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(new SftpSubsystemFactory()));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator;
new File(pathname).mkdirs();
server.setFileSystemFactory(new VirtualFileSystemFactory(Paths.get(pathname)));
@@ -103,7 +101,7 @@ public class SftpServerTests {
try {
server.setPublickeyAuthenticator((username, key, session) -> key.equals(allowedKey));
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()));
final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator;
new File(pathname).mkdirs();

View File

@@ -48,6 +48,7 @@ import com.jcraft.jsch.UserInfo;
/**
* @author Gary Russell
* @author Artem Bilan
*
* @since 3.0.2
*/
public class SftpSessionFactoryTests {
@@ -62,7 +63,7 @@ public class SftpSessionFactoryTests {
try {
server.setPasswordAuthenticator((arg0, arg1, arg2) -> true);
server.setPort(0);
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
server.start();
DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();
@@ -108,7 +109,7 @@ public class SftpSessionFactoryTests {
}
@Test
public void testPasswordPassPhraseViaUserInfo() throws Exception {
public void testPasswordPassPhraseViaUserInfo() {
DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();
f.setUser("user");
f.setAllowUnknownKeys(true);
@@ -213,7 +214,7 @@ public class SftpSessionFactoryTests {
server.setPublickeyAuthenticator((username, key, session) -> true);
server.setPort(0);
server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
server.start();
DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();