public void testGetDetails() throws Exception {
    // Setup
    CryptoKey key = CryptoTest.createTestKey(admin.getOrg());
    KickstartFactory.saveCryptoKey(key);
    assertNotNull(KickstartFactory.lookupCryptoKeyById(key.getId(), key.getOrg()));
    flushAndEvict(key);

    // Test
    CryptoKeysHandler handler = new CryptoKeysHandler();
    CryptoKey cryptoKey = handler.getDetails(adminKey, key.getDescription());

    // Verify
    assertNotNull(cryptoKey);
    assertEquals(cryptoKey.getDescription(), cryptoKey.getDescription());
    assertEquals(cryptoKey.getCryptoKeyType().getLabel(), cryptoKey.getCryptoKeyType().getLabel());
    assertEquals(cryptoKey.getKeyString(), cryptoKey.getKeyString());
  }
  public void testCreate() throws Exception {
    // Setup
    String description = "CryptoKeysHandler.testCreate-Description";
    String content = MD5Crypt.md5Hex(RandomStringUtils.random(28));

    // Test
    CryptoKeysHandler handler = new CryptoKeysHandler();
    handler.create(adminKey, description, "GPG", content);

    // Verify
    CryptoKey cryptoKey = KickstartFactory.lookupCryptoKey(description, admin.getOrg());

    assertNotNull(cryptoKey);
    assertEquals(cryptoKey.getDescription(), description);
    assertEquals(cryptoKey.getCryptoKeyType().getLabel(), "GPG");
    assertEquals(cryptoKey.getKeyString(), content);
  }