Discussion:
[2/2] mina-sshd git commit: Create temporary serialized host key file for tests under 'target/temp' folder
l***@apache.org
2018-10-07 04:44:10 UTC
Permalink
Create temporary serialized host key file for tests under 'target/temp' folder


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/42acff5c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/42acff5c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/42acff5c

Branch: refs/heads/master
Commit: 42acff5c593b963f4fb7d2fb0845a2ba6a4220cb
Parents: 20695fd
Author: Lyor Goldstein <***@gmail.com>
Authored: Sat Oct 6 16:41:20 2018 +0300
Committer: Goldstein Lyor <***@cb4.com>
Committed: Sun Oct 7 07:44:02 2018 +0300

----------------------------------------------------------------------
.../org/apache/sshd/server/auth/AsyncAuthTestBase.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/42acff5c/sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTestBase.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTestBase.java b/sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTestBase.java
index 76ce606..ba903f9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTestBase.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTestBase.java
@@ -18,7 +18,9 @@
*/
package org.apache.sshd.server.auth;

-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;

import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.server.SshServer;
@@ -55,9 +57,13 @@ public abstract class AsyncAuthTestBase extends BaseTestSupport {
}
server = SshServer.setUpDefaultServer();
if (timeout != null) {
- server.getProperties().put(FactoryManager.AUTH_TIMEOUT, timeout.toString());
+ Map<String, Object> props = server.getProperties();
+ props.put(FactoryManager.AUTH_TIMEOUT, timeout.toString());
}
- server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
+
+ Path tmpDir = Files.createDirectories(getTempTargetFolder());
+ Path keyFile = tmpDir.resolve("hostkey.ser");
+ server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(keyFile));
server.setPasswordAuthenticator((username, password, session) -> authenticator.authenticate(username, password, session));
server.setShellFactory(new EchoShellFactory());
server.start();

Loading...