Package org.jclouds.trmk.vcloud_0_8.domain

Examples of org.jclouds.trmk.vcloud_0_8.domain.KeyPair


public class KeyPairByNameHandlerTest extends BaseHandlerTest {

   public void testGood() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/keysList.xml");

      KeyPair result = factory.create(
            addOrgAndNameToHandler(injector.getInstance(KeyPairByNameHandler.class), "org", "default")).parse(is);
      assertEquals(result,
            new KeyPair(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/key/9"),
                  "default", true, null, "4e:af:8a:9f:e9:d2:72:d7:4b:a0:da:98:72:98:4d:7d"));

   }
View Full Code Here


   }

   public void testNotFound() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/keysList.xml");

      KeyPair result = factory.create(
            addOrgAndNameToHandler(injector.getInstance(KeyPairByNameHandler.class), "org", "monster")).parse(is);
      assertNull(result);
   }
View Full Code Here

      TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();

      // create mocks
      CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
      LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();
      KeyPair keyPair = createMock(KeyPair.class);

      // setup expectations
      expect(strategy.credentialStore.containsKey("group#group")).andReturn(false);
      expect(strategy.createUniqueKeyPair.apply(new OrgAndName(org, "group"))).andReturn(keyPair);
      expect(keyPair.getFingerPrint()).andReturn(KeyPairHandlerTest.keyPair.getFingerPrint()).atLeastOnce();
      expect(strategy.credentialStore.put("group#group", keyPairCredentials)).andReturn(null);

      // replay mocks
      replay(keyPair);
      replayStrategy(strategy);
View Full Code Here

            "fa:69:2c:0c:81:03:80:39:33:4d:de:ef:13:3c:e6:ef");

   public void testGood() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/key.xml");

      KeyPair result = factory.create(injector.getInstance(KeyPairHandler.class)).parse(is);

      assertEquals(result, keyPair);
      assertEquals(result.getFingerPrint(), SshKeys.fingerprintPrivateKey(result.getPrivateKey()));
   }
View Full Code Here

      return returnVal.equals("") ? null : returnVal;
   }

   @Override
   public KeyPair getResult() {
      return new KeyPair(location, name, isDefault, privateKey, fingerPrint);
   }
View Full Code Here

               checkState(creds.getOptionalPrivateKey().isPresent(),
                        "incorrect state: should have private key for: %s", creds);
               options.sshKeyFingerprint(SshKeys.fingerprintPrivateKey(creds.getPrivateKey()));
            } else {
               // otherwise create a new keypair and key it under the group
               KeyPair keyPair = createUniqueKeyPair.apply(new OrgAndName(org, group));
               credentialStore.put("group#" + group, LoginCredentials.builder().user(identity).privateKey(
                        keyPair.getPrivateKey()).build());
               options.sshKeyFingerprint(keyPair.getFingerPrint());
            }
         }

      }
View Full Code Here

   private KeyPair createNewKeyPairInOrg(URI org, String keyPairName) {
      checkNotNull(org, "org");
      checkNotNull(keyPairName, "keyPairName");
      logger.debug(">> creating keyPair org(%s) name(%s)", org, keyPairName);
      KeyPair keyPair = null;
      while (keyPair == null) {
         try {
            keyPair = trmkClient.generateKeyPairInOrg(org, getNextName(keyPairName), false);
            logger.debug("<< created keyPair(%s)", keyPair.getName());
         } catch (RuntimeException e) {
            HttpResponseException ht = Throwables2.getFirstThrowableOfType(e, HttpResponseException.class);
            if (ht == null || ht.getContent() == null
                  || ht.getContent().indexOf("Security key with same name exists") == -1)
               throw e;
View Full Code Here

      // setup constants
      OrgAndName orgTag = new OrgAndName(org, "tag");

      // create mocks
      DeleteKeyPair strategy = setupStrategy();
      KeyPair keyPair = createMock(KeyPair.class);

      // setup expectations
      expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
      expect(keyPair.getName()).andReturn("jclouds_" + orgTag.getName() + "_123").atLeastOnce();
      expect(keyPair.getId()).andReturn(URI.create("1245"));
      strategy.terremarkClient.deleteKeyPair(URI.create("1245"));
      expect(strategy.credentialStore.remove("group#tag")).andReturn(null);

      // replay mocks
      replay(keyPair);
View Full Code Here

      // setup constants
      OrgAndName orgTag = new OrgAndName(org, "tag");

      // create mocks
      DeleteKeyPair strategy = setupStrategy();
      KeyPair keyPair = createMock(KeyPair.class);

      // setup expectations
      expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
      expect(keyPair.getName()).andReturn("kclouds_" + orgTag.getName() + "_123");

      // replay mocks
      replay(keyPair);
      replayStrategy(strategy);
View Full Code Here

   public void test1() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/keysList.xml");

      Set<KeyPair> result = factory.create(injector.getInstance(KeyPairsHandler.class)).parse(is);
      assertEquals(result, ImmutableSet.of(new KeyPair(URI
            .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/key/9"), "default", true,
            null, "4e:af:8a:9f:e9:d2:72:d7:4b:a0:da:98:72:98:4d:7d")));

   }
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.domain.KeyPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.