コード例 #1
0
  @Test
  public void listKeypairs() throws CloudException, InternalException {
    IdentityServices services = tm.getProvider().getIdentityServices();

    if (services != null) {
      ShellKeySupport support = services.getShellKeySupport();

      if (support != null) {
        Iterable<SSHKeypair> keypairs = support.list();
        boolean found = false;
        int count = 0;

        assertNotNull("The list of keypairs may not be null", keypairs);
        for (SSHKeypair keypair : keypairs) {
          count++;
          tm.out("Keypair", keypair);
          if (testKeyId != null && testKeyId.equals(keypair.getProviderKeypairId())) {
            found = true;
          }
        }
        tm.out("Total Keypair Count", count);
        if (count < 1) {
          tm.warn("No keypairs were found, so this test may have been invalid");
        }
        if (testKeyId != null) {
          assertNotNull("Unable to find the test keypair among the listed keypairs", found);
        } else {
          tm.warn("No test key exists, so unable to validate key listing");
        }
      } else {
        tm.ok("No shell key support in this cloud");
      }
    } else {
      tm.ok("No identity services in this cloud");
    }
  }
コード例 #2
0
  @Test
  public void keypairContent() throws CloudException, InternalException {
    IdentityServices services = tm.getProvider().getIdentityServices();

    if (services != null) {
      ShellKeySupport support = services.getShellKeySupport();

      if (support != null) {
        if (testKeyId != null) {
          SSHKeypair keypair = support.getKeypair(testKeyId);

          assertNotNull("Failed to find the test keypair", keypair);
          tm.out("Keypair ID", keypair.getProviderKeypairId());
          tm.out("Name", keypair.getName());
          tm.out("Owner Account", keypair.getProviderOwnerId());
          tm.out("Region ID", keypair.getProviderRegionId());
          tm.out("Fingerprint", keypair.getFingerprint());
          tm.out("Public Key", keypair.getPublicKey());
          tm.out("PrivateKey", keypair.getPrivateKey());

          assertNotNull("Keypair ID may not be null", keypair.getProviderKeypairId());
          assertNotNull("Keypair name may not be null", keypair.getName());
          assertNotNull("Keypair owning account may not be null", keypair.getProviderOwnerId());
          assertEquals(
              "Keypair region must match current region context",
              tm.getContext().getRegionId(),
              keypair.getProviderRegionId());
          if (keypair.getFingerprint() == null) {
            tm.warn("A keypair really, really should have a fingerprint if supported by the cloud");
          }
        } else {
          tm.warn("No test key was specified, this test is probably invalid");
        }
      } else {
        tm.ok("No shell key support in this cloud");
      }
    } else {
      tm.ok("No identity services in this cloud");
    }
  }