use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey in project cloudbreak by hortonworks.
the class PlatformResourceClientService method getEncryptionKeys.
public CloudEncryptionKeys getEncryptionKeys(String envCrn, String region) {
LOGGER.info("Fetch encryption keys by environment crn: {} and region: {}", envCrn, region);
PlatformEncryptionKeysResponse encryptionKeys = environmentPlatformResourceEndpoint.getEncryptionKeys(envCrn, region, null, null);
Set<CloudEncryptionKey> keys = encryptionKeys.getEncryptionKeyConfigs().stream().map(response -> new CloudEncryptionKey(response.getName(), response.getId(), response.getDescription(), response.getDisplayName(), response.getProperties())).collect(Collectors.toSet());
return new CloudEncryptionKeys(keys);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey in project cloudbreak by hortonworks.
the class CloudEncryptionKeysToPlatformEncryptionKeysV1ResponseConverter method convert.
public PlatformEncryptionKeysResponse convert(CloudEncryptionKeys source) {
PlatformEncryptionKeysResponse platformEncryptionKeysResponse = new PlatformEncryptionKeysResponse();
Set<EncryptionKeyConfigResponse> result = new HashSet<>();
for (CloudEncryptionKey entry : source.getCloudEncryptionKeys()) {
EncryptionKeyConfigResponse actual = new EncryptionKeyConfigResponse(entry.getName(), entry.getId(), entry.getDescription(), entry.getDisplayName(), entry.getProperties());
result.add(actual);
}
platformEncryptionKeysResponse.setEncryptionKeyConfigs(result);
return platformEncryptionKeysResponse;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey in project cloudbreak by hortonworks.
the class EncryptionKeyArnValidatorTest method testWithValidEncryptionKeyWithAwsListKeysCall.
@Test
void testWithValidEncryptionKeyWithAwsListKeysCall() {
String validKey = "arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab";
EnvironmentDto environmentDto = createEnvironmentDto(validKey);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
CloudEncryptionKey testInput = new CloudEncryptionKey();
testInput.setName("arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab");
CloudEncryptionKeys cloudEncryptionKeys = new CloudEncryptionKeys(Set.of(testInput));
when(retryService.testWith2SecDelayMax15Times(any(Supplier.class))).thenReturn(cloudEncryptionKeys);
ValidationResult validationResult = underTest.validate(environmentValidationDto);
assertFalse(validationResult.hasError());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey in project cloudbreak by hortonworks.
the class EncryptionKeyArnValidatorTest method testWithInvalidEncryptionKeyWithAwsListKeysCall.
@Test
void testWithInvalidEncryptionKeyWithAwsListKeysCall() {
String invalidKey = "arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab";
EnvironmentDto environmentDto = createEnvironmentDto(invalidKey);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
CloudEncryptionKey testInput = new CloudEncryptionKey();
testInput.setName("arn:aws:kms:eu-west-2:123456789012:key/1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p");
CloudEncryptionKeys cloudEncryptionKeys = new CloudEncryptionKeys(Set.of(testInput));
when(retryService.testWith2SecDelayMax15Times(any(Supplier.class))).thenReturn(cloudEncryptionKeys);
ValidationResult validationResult = underTest.validate(environmentValidationDto);
assertTrue(validationResult.hasError());
assertEquals(String.format("The provided encryption key does not exist in the given region's encryption key list for this credential."), validationResult.getFormattedErrors());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey in project cloudbreak by hortonworks.
the class StackAwsEncryptionValidatorTest method createPlatformEncryptionKeysResponseWithNameValue.
private CloudEncryptionKeys createPlatformEncryptionKeysResponseWithNameValue() {
CloudEncryptionKey testInput = new CloudEncryptionKey();
testInput.setName(TEST_ENCRYPTION_KEY);
return new CloudEncryptionKeys(Set.of(testInput));
}
Aggregations