use of com.sequenceiq.cloudbreak.cloud.model.encryption.DiskEncryptionSetDeletionRequest in project cloudbreak by hortonworks.
the class AzureEncryptionResourcesTest method testDeleteDiskEncryptionSetShouldReturnSilentlyWhenThereIsNoCloudResource.
@Test
void testDeleteDiskEncryptionSetShouldReturnSilentlyWhenThereIsNoCloudResource() {
List<CloudResource> resources = List.of();
DiskEncryptionSetDeletionRequest deletionRequest = new DiskEncryptionSetDeletionRequest.Builder().withCloudCredential(cloudCredential).withCloudContext(cloudContext).withCloudResources(resources).build();
initCloudResourceHelper(resources);
underTest.deleteDiskEncryptionSet(deletionRequest);
verify(azureClientService, never()).getClient(any(CloudCredential.class));
}
use of com.sequenceiq.cloudbreak.cloud.model.encryption.DiskEncryptionSetDeletionRequest in project cloudbreak by hortonworks.
the class AzureEncryptionResourcesTest method testDeleteDiskEncryptionSetShouldNotMakeCloudCallWhenDiskEncryptionSetIsNotFound.
@Test
public void testDeleteDiskEncryptionSetShouldNotMakeCloudCallWhenDiskEncryptionSetIsNotFound() {
List<CloudResource> resources = getResources("/subscriptions/dummySubscriptionId/resourceGroups/dummyResourceGroup/providers/" + "Microsoft.Compute/diskEncryptionSets/dummyDesId");
DiskEncryptionSetDeletionRequest deletionRequest = new DiskEncryptionSetDeletionRequest.Builder().withCloudCredential(cloudCredential).withCloudContext(cloudContext).withCloudResources(resources).build();
initCloudResourceHelper(resources);
when(azureClient.getDiskEncryptionSetByName(any(), any())).thenReturn(null);
when(azureClientService.getClient(cloudCredential)).thenReturn(azureClient);
initRetry();
underTest.deleteDiskEncryptionSet(deletionRequest);
verify(azureClient, never()).deleteDiskEncryptionSet("dummyResourceGroup", "dummyDesId");
verify(persistenceNotifier).notifyDeletion(deletionRequest.getCloudResources().iterator().next(), deletionRequest.getCloudContext());
}
use of com.sequenceiq.cloudbreak.cloud.model.encryption.DiskEncryptionSetDeletionRequest in project cloudbreak by hortonworks.
the class EnvironmentEncryptionServiceTest method verifyDiskEncryptionSetDeletionRequestForResourceGroup.
private void verifyDiskEncryptionSetDeletionRequestForResourceGroup() {
DiskEncryptionSetDeletionRequest deletionRequest = diskEncryptionSetDeletionRequestCaptor.getValue();
List<CloudResource> cloudResources = deletionRequest.getCloudResources();
Optional<CloudResource> rgCloudResourceOptional = cloudResources.stream().filter(r -> r.getType() == ResourceType.AZURE_RESOURCE_GROUP).findFirst();
assertThat(rgCloudResourceOptional).isNotEmpty();
CloudResource rgCloudResource = rgCloudResourceOptional.get();
assertEquals(rgCloudResource.getReference(), "uniqueDummyId");
assertEquals(rgCloudResource.getName(), "dummyenv-CDP_DES-ResourceGroup");
assertEquals(rgCloudResource.getType(), ResourceType.AZURE_RESOURCE_GROUP);
}
use of com.sequenceiq.cloudbreak.cloud.model.encryption.DiskEncryptionSetDeletionRequest in project cloudbreak by hortonworks.
the class EnvironmentEncryptionServiceTest method testCreateEncryptionResourcesDeletionRequestShouldReturnWithANewDeletionRequest.
@Test
void testCreateEncryptionResourcesDeletionRequestShouldReturnWithANewDeletionRequest() {
EnvironmentDto environmentDto = EnvironmentDto.builder().withResourceCrn(ENVIRONMENT_CRN).withId(ENVIRONMENT_ID).withName(ENVIRONMENT_NAME).withCloudPlatform(CLOUD_PLATFORM).withCredential(credential).withLocationDto(LocationDto.builder().withName(REGION).build()).withParameters(ParametersDto.builder().withAzureParameters(AzureParametersDto.builder().withEncryptionParameters(AzureResourceEncryptionParametersDto.builder().withDiskEncryptionSetId(DISK_ENCRYPTION_SET_ID).withEncryptionKeyUrl(KEY_URL).build()).build()).build()).withCreator(USER_NAME).withAccountId(ACCOUNT_ID).build();
CloudResource desCloudResource = CloudResource.builder().name(DISK_ENCRYPTION_SET_NAME).type(ResourceType.AZURE_DISK_ENCRYPTION_SET).reference(DISK_ENCRYPTION_SET_ID).status(CommonStatus.CREATED).build();
when(resourceRetriever.findByEnvironmentIdAndType(ENVIRONMENT_ID, ResourceType.AZURE_DISK_ENCRYPTION_SET)).thenReturn(Optional.of(desCloudResource));
when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
DiskEncryptionSetDeletionRequest deletionRequest = underTest.createEncryptionResourcesDeletionRequest(environmentDto);
Optional<CloudResource> dummyResourceOptional = deletionRequest.getCloudResources().stream().filter(r -> r.getType() == ResourceType.AZURE_DISK_ENCRYPTION_SET).findFirst();
assertNotNull(dummyResourceOptional);
assertThat(dummyResourceOptional).isNotEmpty();
assertEquals(dummyResourceOptional.get().getReference(), DISK_ENCRYPTION_SET_ID);
verifyCloudContext(deletionRequest.getCloudContext());
assertThat(deletionRequest.getCloudCredential()).isSameAs(cloudCredential);
}
use of com.sequenceiq.cloudbreak.cloud.model.encryption.DiskEncryptionSetDeletionRequest in project cloudbreak by hortonworks.
the class EnvironmentEncryptionServiceTest method verifyDiskEncryptionSetDeletionRequestForDes.
private void verifyDiskEncryptionSetDeletionRequestForDes() {
DiskEncryptionSetDeletionRequest deletionRequest = diskEncryptionSetDeletionRequestCaptor.getValue();
CloudContext cloudContext = deletionRequest.getCloudContext();
List<CloudResource> cloudResources = deletionRequest.getCloudResources();
Optional<CloudResource> desCloudResourceOptional = cloudResources.stream().filter(r -> r.getType() == ResourceType.AZURE_DISK_ENCRYPTION_SET).findFirst();
assertThat(desCloudResourceOptional).isNotEmpty();
CloudResource desCloudResource = desCloudResourceOptional.get();
assertEquals(desCloudResource.getReference(), DISK_ENCRYPTION_SET_ID);
assertEquals(desCloudResource.getName(), DISK_ENCRYPTION_SET_NAME);
assertEquals(desCloudResource.getType(), ResourceType.AZURE_DISK_ENCRYPTION_SET);
assertEquals(cloudContext.getAccountId(), ACCOUNT_ID);
assertEquals(cloudContext.getCrn(), ENVIRONMENT_CRN);
}
Aggregations