use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys 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.CloudEncryptionKeys 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.CloudEncryptionKeys 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.CloudEncryptionKeys 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));
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getEncryptionKeys.
@Override
@CustomPermissionCheck
public PlatformEncryptionKeysResponse getEncryptionKeys(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone) {
customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
String accountId = getAccountId();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone);
LOGGER.info("Get /platform_resources/encryption_keys, request: {}", request);
CloudEncryptionKeys encryptionKeys = platformParameterService.getEncryptionKeys(request);
PlatformEncryptionKeysResponse response = cloudEncryptionKeysToPlatformEncryptionKeysV1ResponseConverter.convert(encryptionKeys);
LOGGER.info("Resp /platform_resources/encryption_keys, request: {}, ipPools: {}, response: {}", request, encryptionKeys, response);
return response;
}
Aggregations