keyPair = checkNotNull(novaApi.getKeyPairApi(region).get().get(templateOptions.getKeyPairName()), "keypair %s doesn't exist", templateOptions.getKeyPairName());
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } } }
keyPair = checkNotNull(novaApi.getKeyPairApi(region).get().get(templateOptions.getKeyPairName()), "keypair %s doesn't exist", templateOptions.getKeyPairName());
public void testCreateAndGetAndDeleteKeyPair() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.create(KEYPAIR_NAME); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } }
public void testGetKeyPairWhenResponseIs2xx() throws Exception { HttpRequest get = HttpRequest .builder() .method("GET") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); HttpResponse getResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/keypair_details.json")).build(); NovaApi apiWhenKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse); assertEquals(apiWhenKeyPairExists.getKeyPairApi("az-1.region-a.geo-1").get().get("testkeypair"), new ParseKeyPairTest().expected()); }