@Test(groups = "Integration")
public void testExtractingConnectablePassphraselessKey() throws Exception {
Maybe<LocationSpec<? extends Location>> lhps = mgmt.getLocationRegistry().getLocationSpec("named:localhost-passphrase");
Preconditions.checkArgument(lhps.isPresent(), "This test requires a localhost named location called 'localhost-passphrase' (which should have a passphrase set)");
LocalhostMachineProvisioningLocation lhp = (LocalhostMachineProvisioningLocation) mgmt.getLocationManager().createLocation(lhps.get());
SshMachineLocation sm = lhp.obtain();
SshjToolBuilder builder = SshjTool.builder().host(sm.getAddress().getHostName()).user(sm.getUser());
KeyPair data = sm.findKeyPair();
if (data!=null) builder.privateKeyData(SecureKeys.toPem(data));
String password = sm.findPassword();
if (password!=null) builder.password(password);
SshjTool tool = builder.build();
tool.connect();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int result = tool.execCommands(MutableMap.<String,Object>of("out", out), Arrays.asList("date"));
Assert.assertTrue(out.toString().contains(" 20"), "out="+out);
assertEquals(result, 0);
}