mirror of https://github.com/apache/jclouds.git
removed dsa keypair test as we currently do not support this
This commit is contained in:
parent
8bd4fb483a
commit
e1c813d82c
|
@ -25,21 +25,20 @@ import java.io.FileInputStream;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshException;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
@ -113,11 +112,12 @@ public class JschSshClientLiveTest {
|
|||
Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule());
|
||||
SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
|
||||
SshClient connection;
|
||||
if (sshKeyFile != null && !sshKeyFile.trim().equals("")) {
|
||||
connection = factory.create(new IPSocket(sshHost, port),
|
||||
new Credentials(sshUser, Strings2.toStringAndClose(new FileInputStream(sshKeyFile))));
|
||||
if (Strings.emptyToNull(sshKeyFile) != null) {
|
||||
connection = factory.create(new IPSocket(sshHost, port), LoginCredentials.builder().user(sshUser)
|
||||
.privateKey(Strings2.toStringAndClose(new FileInputStream(sshKeyFile))).build());
|
||||
} else {
|
||||
connection = factory.create(new IPSocket(sshHost, port), new Credentials(sshUser, sshPass));
|
||||
connection = factory.create(new IPSocket(sshHost, port),
|
||||
LoginCredentials.builder().user(sshUser).password(sshPass).build());
|
||||
}
|
||||
connection.connect();
|
||||
return connection;
|
||||
|
@ -147,44 +147,4 @@ public class JschSshClientLiveTest {
|
|||
: sshHost);
|
||||
}
|
||||
|
||||
// Seems to be using oauth now instead of bouncycastle and is more strict.
|
||||
// Commands used to generate this key are:
|
||||
// openssl dsaparam -outform PEM 2048 > dsaparams
|
||||
// openssl gendsa -aes256 -out privkey.pem dsaparams
|
||||
private static final String key = "-----BEGIN DSA PRIVATE KEY-----\n" +
|
||||
"Proc-Type: 4,ENCRYPTED\n" +
|
||||
"DEK-Info: AES-256-CBC,8C3A84B8BDA9FE69AAB4A322D7795161\n" +
|
||||
"\n" +
|
||||
"B8nuwNIcw5UtV9gGX2LiOq5OZ0uDgWsRon/mmWu+8EFd6X1aautVw8pCZuNusNkS\n" +
|
||||
"GZlO1JBIgKdX6Qqx0cPsirFB7GTNbBVHOIMqYbmQKW5Ju+n+NkNIomDJDJqBWknE\n" +
|
||||
"ZIkegznvdLN11r6F4jreusnVepSNYeRwKxA5KAT0S6XsgVFKSJZIyJj8EKZl/25D\n" +
|
||||
"a7LKoYRlf5QK+Q1/zmMyZcCt0irIMcHxslpVlyATajAADB0hwBl4Xh0H3oHR3PU1\n" +
|
||||
"xhsliYTARGov6Wn7adDCG9zWDzO7cX3941ub0FPoDdPLxGkmwqEwijF1XWvYbIUC\n" +
|
||||
"EBjomG3pwjC1kfoqAYJhThi8vmQYtFyCagcZMauHDKuqwUr1o3jS51PBe3bKeg4M\n" +
|
||||
"dP/JSTiTAUGtwV/MobThQFvCWJm22jIR6Eb0IYPcncUQuZ1QO2piwSvMUZZYCFX/\n" +
|
||||
"uY7fHkPZyBkZIrxGc91jhSQlo8qsVBIThJpLYI2M2PjKxTzsgZ2mWWK/Zm7pVqqI\n" +
|
||||
"ldTJ1cpSMb2/9BsXF0CWvzaC4qN5Ymmrp152M4ZEnsRN3ycd9wFCD2cM7w5frj4Z\n" +
|
||||
"3Q3M9/qNYuPfHddJa1DIkYpZxTTzOo4BBWx2O32D3in+2YZWjBgdxej17hKVkmUR\n" +
|
||||
"C432CtEqUYAtVv//3TZ47hYsywvvVEX/3ljcCObrHKDha6i3SwXMqe1tL3BYexOn\n" +
|
||||
"LS8aGQ148oekWaSWYrXCo0gjuJgY3hJZKUHoKdhvyW/FZG3rMjk5NlU9IwjMweqz\n" +
|
||||
"Bznl7sMxHqtW4BPV9fM4uaiM8LOMkIm6euu/1a2o///TaEgFr/H1ybLdcg8Au1Iy\n" +
|
||||
"sH68Xn+pmkx1bdVCCpi44EtAEHrpX11AC+cuvu8KG0A+Tpy3WW7YXYkregEQM3kF\n" +
|
||||
"XzzyJfHuZKvM7qXsMnt/T5VCYX1LSEtXFABFMHDsPC9qs1LVLdSC5U0Ux0Ac0Sqq\n" +
|
||||
"MRG2Yc8hDOPvPOmiqD9OK9PC6fa+bbMEtlS2O5Cd0l+hoE8OD1EFP1hAGQ0ivjZT\n" +
|
||||
"zMJXBUVUtYAkrpU6NcY+ub7IyYBR3wOWSAUbolx3K4p2o8k3MGFdLHb4dGvypIv2\n" +
|
||||
"oHhZLNLYGPrAN2g0gpNmlepDS1aG6422770O/Eh1bDXDyGYJRW3INwWenN8KbuYd\n" +
|
||||
"-----END DSA PRIVATE KEY-----";
|
||||
|
||||
public void testPrivateKeyWithPassphrase() throws UnknownHostException {
|
||||
Injector i = Guice.createInjector(new JschSshClientModule(),new SLF4JLoggingModule());
|
||||
SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
|
||||
try {
|
||||
JschSshClient ssh = JschSshClient.class.cast(factory.create(new IPSocket("localhost", 22), new Credentials(
|
||||
"username", key)));
|
||||
ssh.connect();
|
||||
assert false; // this code should never be reached.
|
||||
} catch (SshException e) {
|
||||
// Success!
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue