@Test
  public void getBogusKeypair() throws CloudException, InternalException {
    IdentityServices services = tm.getProvider().getIdentityServices();

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

      if (support != null) {
        SSHKeypair keypair = support.getKeypair(UUID.randomUUID().toString());

        tm.out("Bogus Keypair", keypair);
        assertNull("Found a bogus keypair when none should exist", keypair);
      } else {
        tm.ok("No shell key support in this cloud");
      }
    } else {
      tm.ok("No identity services in this cloud");
    }
  }
  @Test
  public void getKeypair() 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);

          tm.out("Keypair", keypair);
          assertNotNull("Failed to find the test keypair", keypair);
        } 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");
    }
  }
  @Test
  public void checkMetaData() throws CloudException, InternalException {
    IdentityServices services = tm.getProvider().getIdentityServices();

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

      if (support != null) {
        tm.out("Subscribed", support.isSubscribed());
        tm.out("Term for Keypair", support.getProviderTermForKeypair(Locale.getDefault()));
        tm.out("Key Import Req", support.getKeyImportSupport());
      } else {
        tm.ok("No shell key support in this cloud");
      }
    } else {
      tm.ok("No identity services in this cloud");
    }
  }
  @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");
    }
  }
 @After
 public void after() {
   tm.end();
 }
 @Before
 public void before() {
   tm.begin(name.getMethodName());
   assumeTrue(!tm.isTestSkipped());
   testKeyId = tm.getTestKeypairId(DaseinTestManager.STATELESS, false);
 }
 @AfterClass
 public static void cleanUp() {
   if (tm != null) {
     tm.close();
   }
 }
  @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");
    }
  }