use of com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testUpdateAwsDiskEncryptionParametersByEnvironmentName.
@Test
void testUpdateAwsDiskEncryptionParametersByEnvironmentName() {
UpdateAwsDiskEncryptionParametersDto updateAwsDiskEncryptionParametersDto = UpdateAwsDiskEncryptionParametersDto.builder().withAwsDiskEncryptionParametersDto(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyKeyArn").build()).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withParameters(ParametersDto.builder().withAwsParameters(AwsParametersDto.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyKeyArn").build()).build()).build()).build();
Environment env = new Environment();
env.setParameters(new AwsParameters());
when(environmentService.getValidatorService()).thenReturn(validatorService);
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(env));
when(validatorService.validateEncryptionKeyArn(any(String.class), any(String.class))).thenReturn(ValidationResult.builder().build());
when(environmentDtoConverter.environmentToDto(env)).thenReturn(environmentDto);
EnvironmentDto envDto = environmentModificationServiceUnderTest.updateAwsDiskEncryptionParametersByEnvironmentName(ACCOUNT_ID, ENVIRONMENT_NAME, updateAwsDiskEncryptionParametersDto);
assertEquals(envDto.getParameters().getAwsParametersDto().getAwsDiskEncryptionParametersDto().getEncryptionKeyArn(), "dummyKeyArn");
ArgumentCaptor<AwsParameters> awsParametersArgumentCaptor = ArgumentCaptor.forClass(AwsParameters.class);
verify(awsParametersRepository).save(awsParametersArgumentCaptor.capture());
assertEquals("dummyKeyArn", awsParametersArgumentCaptor.getValue().getEncryptionKeyArn());
}
use of com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testUpdateAwsDiskEncryptionParametersByEnvironmentCrn.
@Test
void testUpdateAwsDiskEncryptionParametersByEnvironmentCrn() {
UpdateAwsDiskEncryptionParametersDto updateAwsDiskEncryptionParametersDto = UpdateAwsDiskEncryptionParametersDto.builder().withAwsDiskEncryptionParametersDto(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyKeyArn").build()).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withParameters(ParametersDto.builder().withAwsParameters(AwsParametersDto.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyKeyArn").build()).build()).build()).build();
Environment env = new Environment();
env.setParameters(new AwsParameters());
when(environmentService.getValidatorService()).thenReturn(validatorService);
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(eq(CRN), eq(ACCOUNT_ID))).thenReturn(Optional.of(env));
when(validatorService.validateEncryptionKeyArn(any(String.class), any(String.class))).thenReturn(ValidationResult.builder().build());
when(environmentDtoConverter.environmentToDto(env)).thenReturn(environmentDto);
EnvironmentDto envDto = environmentModificationServiceUnderTest.updateAwsDiskEncryptionParametersByEnvironmentCrn(ACCOUNT_ID, CRN, updateAwsDiskEncryptionParametersDto);
assertEquals(envDto.getParameters().getAwsParametersDto().getAwsDiskEncryptionParametersDto().getEncryptionKeyArn(), "dummyKeyArn");
ArgumentCaptor<AwsParameters> awsParametersArgumentCaptor = ArgumentCaptor.forClass(AwsParameters.class);
verify(awsParametersRepository).save(awsParametersArgumentCaptor.capture());
assertEquals("dummyKeyArn", awsParametersArgumentCaptor.getValue().getEncryptionKeyArn());
}
use of com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentController method updateAwsDiskEncryptionParametersByEnvironmentName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.UPDATE_AWS_DISK_ENCRYPTION_PARAMETERS)
public DetailedEnvironmentResponse updateAwsDiskEncryptionParametersByEnvironmentName(@ResourceName String environmentName, @RequestObject @Valid UpdateAwsDiskEncryptionParametersRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
UpdateAwsDiskEncryptionParametersDto dto = environmentApiConverter.convertUpdateAwsDiskEncryptionParametersDto(request);
EnvironmentDto result = environmentModificationService.updateAwsDiskEncryptionParametersByEnvironmentName(accountId, environmentName, dto);
return environmentResponseConverter.dtoToDetailedResponse(result);
}
use of com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentController method updateAwsDiskEncryptionParametersByEnvironmentCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.UPDATE_AWS_DISK_ENCRYPTION_PARAMETERS)
public DetailedEnvironmentResponse updateAwsDiskEncryptionParametersByEnvironmentCrn(@ValidCrn(resource = CrnResourceDescriptor.ENVIRONMENT) @ResourceCrn String crn, @RequestObject @Valid UpdateAwsDiskEncryptionParametersRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
UpdateAwsDiskEncryptionParametersDto dto = environmentApiConverter.convertUpdateAwsDiskEncryptionParametersDto(request);
EnvironmentDto result = environmentModificationService.updateAwsDiskEncryptionParametersByEnvironmentCrn(accountId, crn, dto);
return environmentResponseConverter.dtoToDetailedResponse(result);
}
use of com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testConvertUpdateAwsDiskEncryptionParametersDto.
@Test
void testConvertUpdateAwsDiskEncryptionParametersDto() {
UpdateAwsDiskEncryptionParametersRequest request = UpdateAwsDiskEncryptionParametersRequest.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn(ENCRYPTION_KEY_ARN).build()).build();
UpdateAwsDiskEncryptionParametersDto actual = underTest.convertUpdateAwsDiskEncryptionParametersDto(request);
assertEquals(ENCRYPTION_KEY_ARN, actual.getAwsDiskEncryptionParametersDto().getEncryptionKeyArn());
}
Aggregations