From 9fbc3068f22497b1e3c53687b8a865f5cf7ad427 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Jun 2010 09:08:07 -0600 Subject: [PATCH] Issue 220: changed test to use dummy credentials --- .../compute/BaseComputeServiceLiveTest.java | 19 +++++++++++-------- .../StubComputeServiceIntegrationTest.java | 11 +++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index f8c5b3d2ab..cbd68de64d 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -104,6 +104,17 @@ public abstract class BaseComputeServiceLiveTest { if (tag == null) tag = checkNotNull(service, "service"); setupCredentials(); + setupKeyPair(); + initializeContextAndClient(); + + Injector injector = createSshClientInjector(); + sshFactory = injector.getInstance(SshClient.Factory.class); + SocketOpen socketOpen = injector.getInstance(SocketOpen.class); + socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); + injector.injectMembers(socketOpen); // add logger + } + + protected void setupKeyPair() throws FileNotFoundException, IOException { String secretKeyFile; try { 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; keyPair = ImmutableMap. of("private", secret, "public", Files.toString( 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(socketOpen, 60, 1, TimeUnit.SECONDS); - injector.injectMembers(socketOpen); // add logger - // keyPair = sshFactory.generateRSAKeyPair("", ""); } protected void setupCredentials() { diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index fe00ab6bfc..903b0a02cd 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -27,6 +27,7 @@ import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.testng.Assert.assertEquals; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; @@ -163,11 +164,11 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes new SshException("Auth fail")); expect(factory.create(new IPSocket("144.175.1.1", 22), "root", "password1")).andReturn( client1).atLeastOnce(); - + client1.connect(); runScript(client1, "computeserv", 1); client1.disconnect(); - + expect(factory.create(new IPSocket("144.175.1.2", 22), "root", "password2")).andReturn( client2).atLeastOnce(); 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. of("public", "ssh-rsa", "private", + "-----BEGIN RSA PRIVATE KEY-----"); + } + } \ No newline at end of file