Issue 220: changed test to use dummy credentials

This commit is contained in:
Adrian Cole 2010-06-01 09:08:07 -06:00
parent 14e16fbfa6
commit 9fbc3068f2
2 changed files with 20 additions and 10 deletions

View File

@ -104,6 +104,17 @@ public abstract class BaseComputeServiceLiveTest {
if (tag == null) if (tag == null)
tag = checkNotNull(service, "service"); tag = checkNotNull(service, "service");
setupCredentials(); setupCredentials();
setupKeyPair();
initializeContextAndClient();
Injector injector = createSshClientInjector();
sshFactory = injector.getInstance(SshClient.Factory.class);
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS);
injector.injectMembers(socketOpen); // add logger
}
protected void setupKeyPair() throws FileNotFoundException, IOException {
String secretKeyFile; String secretKeyFile;
try { try {
secretKeyFile = checkNotNull(System.getProperty("jclouds.test.ssh.keyfile"), secretKeyFile = checkNotNull(System.getProperty("jclouds.test.ssh.keyfile"),
@ -116,14 +127,6 @@ public abstract class BaseComputeServiceLiveTest {
assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret; assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret;
keyPair = ImmutableMap.<String, String> of("private", secret, "public", Files.toString( keyPair = ImmutableMap.<String, String> of("private", secret, "public", Files.toString(
new File(secretKeyFile + ".pub"), Charsets.UTF_8)); new File(secretKeyFile + ".pub"), Charsets.UTF_8));
initializeContextAndClient();
Injector injector = createSshClientInjector();
sshFactory = injector.getInstance(SshClient.Factory.class);
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS);
injector.injectMembers(socketOpen); // add logger
// keyPair = sshFactory.generateRSAKeyPair("", "");
} }
protected void setupCredentials() { protected void setupCredentials() {

View File

@ -27,6 +27,7 @@ import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
@ -163,11 +164,11 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
new SshException("Auth fail")); new SshException("Auth fail"));
expect(factory.create(new IPSocket("144.175.1.1", 22), "root", "password1")).andReturn( expect(factory.create(new IPSocket("144.175.1.1", 22), "root", "password1")).andReturn(
client1).atLeastOnce(); client1).atLeastOnce();
client1.connect(); client1.connect();
runScript(client1, "computeserv", 1); runScript(client1, "computeserv", 1);
client1.disconnect(); client1.disconnect();
expect(factory.create(new IPSocket("144.175.1.2", 22), "root", "password2")).andReturn( expect(factory.create(new IPSocket("144.175.1.2", 22), "root", "password2")).andReturn(
client2).atLeastOnce(); client2).atLeastOnce();
expect(factory.create(new IPSocket("144.175.1.3", 22), "root", "password3")).andReturn( expect(factory.create(new IPSocket("144.175.1.3", 22), "root", "password3")).andReturn(
@ -307,4 +308,10 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
} }
@Override
protected void setupKeyPair() throws FileNotFoundException, IOException {
keyPair = ImmutableMap.<String, String> of("public", "ssh-rsa", "private",
"-----BEGIN RSA PRIVATE KEY-----");
}
} }