use of com.sequenceiq.cloudbreak.api.model.PlatformSshKeyResponse in project cloudbreak by hortonworks.
the class CloudSshKeysToPlatformSshKeysResponseConverter method convert.
@Override
public PlatformSshKeysResponse convert(CloudSshKeys source) {
Map<String, Set<PlatformSshKeyResponse>> result = new HashMap<>();
for (Entry<String, Set<CloudSshKey>> entry : source.getCloudSshKeysResponses().entrySet()) {
Set<PlatformSshKeyResponse> sshKeyResponses = new HashSet<>();
for (CloudSshKey cloudSshKey : entry.getValue()) {
PlatformSshKeyResponse actual = new PlatformSshKeyResponse(cloudSshKey.getName(), cloudSshKey.getProperties());
sshKeyResponses.add(actual);
}
result.put(entry.getKey(), sshKeyResponses);
}
return new PlatformSshKeysResponse(result);
}
use of com.sequenceiq.cloudbreak.api.model.PlatformSshKeyResponse in project cloudbreak by hortonworks.
the class ExistingSshKeySelectionTest method testSshKeySelection.
@Test
@Parameters({ "credentialName", "region", "availabilityZone", "selectedKeyName" })
public void testSshKeySelection(@Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, String selectedKeyName) {
// GIVEN
IntegrationTestContext itContext = getItContext();
credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
PlatformResourceRequestJson resourceRequestJson = new PlatformResourceRequestJson();
resourceRequestJson.setCredentialName(credentialName);
resourceRequestJson.setRegion(region);
resourceRequestJson.setAvailabilityZone(availabilityZone);
// WHEN
PlatformSshKeysResponse response = getCloudbreakClient().connectorV1Endpoint().getCloudSshKeys(resourceRequestJson);
// THEN
Set<PlatformSshKeyResponse> regionKeys = response.getSshKeys().get(region);
Assert.assertNotNull(regionKeys, "keys cannot be null for " + region);
java.util.Optional<PlatformSshKeyResponse> selected = regionKeys.stream().filter(rk -> rk.getName().equals(selectedKeyName)).findFirst();
Assert.assertTrue(selected.isPresent(), "the sshkey list doesn't contain [" + selectedKeyName + ']');
getItContext().putContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID, selected.get().getName());
}
use of com.sequenceiq.cloudbreak.api.model.PlatformSshKeyResponse in project cloudbreak by hortonworks.
the class SshKey method assertValidSshKeys.
public static Assertion<SshKey> assertValidSshKeys() {
return assertThis((sshKey, t) -> {
if (sshKey.getResponseWithSshKeys().isEmpty()) {
LOGGER.info("No sshKeys for given provider");
} else {
for (Map.Entry<String, Set<PlatformSshKeyResponse>> elem : sshKey.getResponseWithSshKeys().entrySet()) {
for (Object response : elem.getValue()) {
PlatformSshKeyResponse platformSshKeyResponse = (PlatformSshKeyResponse) response;
Assert.assertFalse(platformSshKeyResponse.getName().isEmpty());
}
}
}
});
}
Aggregations