@Test void testCreateKeyPair() { String keyName = PREFIX + "1"; cleanupKeyPair(keyName); try { KeyPair keyPair = client.createKeyPairInRegion(null, keyName); checkKeyPair(keyName, keyPair); assertNotNull(keyPair.getKeyMaterial()); } finally { cleanupKeyPair(keyName); } }
noSshContext = createView(setupProperties(), ImmutableSet.<Module> of(new Log4JLoggingModule())); AWSRunningInstance instance = getInstance(instanceApi, first.getProviderId());
@Test void testImportKeyPair() throws FileNotFoundException, IOException { String keyName = PREFIX + "2"; cleanupKeyPair(keyName); Map<String, String> myKey = ComputeTestUtils.setupKeyPair(); try { KeyPair keyPair = client.importKeyPairInRegion(null, keyName, myKey.get("public")); checkKeyPair(keyName, keyPair); // TODO generate correct fingerprint and check // assertEquals(keyPair.getKeyFingerprint(), // CryptoStreams.hex(CryptoStreams.md5(myKey.get("public").getBytes()))); // try again to see if there's an error try { client.importKeyPairInRegion(null, keyName, myKey.get("public")); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { } } finally { cleanupKeyPair(keyName); } }