private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
public void testGetKeyReturns404() throws InterruptedException { server.enqueue(response404()); Key key = api.keyApi().get(1); assertNull(key); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1"); }
public void testGetKeyUsingFingerprintReturns404() throws InterruptedException { server.enqueue(response404()); Key key = api.keyApi().get("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); assertNull(key); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); }
public void testGetKey() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().get(1); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1"); }
public void testGetKeyUsingFingerprint() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().get("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); }
@Test(dependsOnMethods = "testCreateKey") public void testUpdateKey() { api().update(dsa.id(), "jclouds-test-dsa-updated"); assertEquals(api().get(dsa.id()).name(), "jclouds-test-dsa-updated"); }