Search in sources :

Example 21 with Backup

use of com.sequenceiq.freeipa.api.model.Backup in project cloudbreak by hortonworks.

the class StackToCloudStackConverterTest method testBuildFileSystemViewDifferentGCPEmail.

@Test
public void testBuildFileSystemViewDifferentGCPEmail() throws Exception {
    Telemetry telemetry = mock(Telemetry.class);
    Backup backup = mock(Backup.class);
    Logging logging = mock(Logging.class);
    GcsCloudStorageV1Parameters gcsLogging = new GcsCloudStorageV1Parameters();
    gcsLogging.setServiceAccountEmail("myaccount1@myprojectid.iam.gserviceaccount.com");
    GcsCloudStorageV1Parameters gcsBackup = new GcsCloudStorageV1Parameters();
    gcsBackup.setServiceAccountEmail("myaccount2@myprojectid.iam.gserviceaccount.com");
    when(stack.getTelemetry()).thenReturn(telemetry);
    when(telemetry.getLogging()).thenReturn(logging);
    when(stack.getBackup()).thenReturn(backup);
    when(backup.getGcs()).thenReturn(gcsBackup);
    when(logging.getGcs()).thenReturn(gcsLogging);
    expectedException.expect(BadRequestException.class);
    underTest.buildFileSystemView(stack);
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) Backup(com.sequenceiq.freeipa.api.model.Backup) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) Test(org.junit.Test)

Example 22 with Backup

use of com.sequenceiq.freeipa.api.model.Backup in project cloudbreak by hortonworks.

the class StackToCloudStackConverterTest method testBuildFileSystemViewDifferentAzureManagedIdentity.

@Test
public void testBuildFileSystemViewDifferentAzureManagedIdentity() throws Exception {
    Telemetry telemetry = mock(Telemetry.class);
    Backup backup = mock(Backup.class);
    Logging logging = mock(Logging.class);
    AdlsGen2CloudStorageV1Parameters adlsGen2Logging = new AdlsGen2CloudStorageV1Parameters();
    adlsGen2Logging.setManagedIdentity("/subscriptions/id/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1");
    AdlsGen2CloudStorageV1Parameters adlsGen2Backup = new AdlsGen2CloudStorageV1Parameters();
    adlsGen2Backup.setManagedIdentity("/subscriptions/id/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2");
    when(stack.getTelemetry()).thenReturn(telemetry);
    when(telemetry.getLogging()).thenReturn(logging);
    when(stack.getBackup()).thenReturn(backup);
    when(backup.getAdlsGen2()).thenReturn(adlsGen2Logging);
    when(logging.getAdlsGen2()).thenReturn(adlsGen2Backup);
    expectedException.expect(BadRequestException.class);
    underTest.buildFileSystemView(stack);
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Test(org.junit.Test)

Example 23 with Backup

use of com.sequenceiq.freeipa.api.model.Backup in project cloudbreak by hortonworks.

the class StackToCloudStackConverterTest method testBuildFileSystemViewSameGCPEmail.

@Test
public void testBuildFileSystemViewSameGCPEmail() throws Exception {
    Telemetry telemetry = mock(Telemetry.class);
    Backup backup = mock(Backup.class);
    Logging logging = mock(Logging.class);
    GcsCloudStorageV1Parameters gcsLogging = new GcsCloudStorageV1Parameters();
    gcsLogging.setServiceAccountEmail("myaccount@myprojectid.iam.gserviceaccount.com");
    GcsCloudStorageV1Parameters gcsBackup = new GcsCloudStorageV1Parameters();
    gcsBackup.setServiceAccountEmail("myaccount@myprojectid.iam.gserviceaccount.com");
    when(stack.getTelemetry()).thenReturn(telemetry);
    when(telemetry.getLogging()).thenReturn(logging);
    when(stack.getBackup()).thenReturn(backup);
    when(backup.getGcs()).thenReturn(gcsBackup);
    when(logging.getGcs()).thenReturn(gcsLogging);
    Optional<CloudFileSystemView> fileSystemView = underTest.buildFileSystemView(stack);
    assertEquals(Optional.empty(), fileSystemView);
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) Backup(com.sequenceiq.freeipa.api.model.Backup) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) Test(org.junit.Test)

Example 24 with Backup

use of com.sequenceiq.freeipa.api.model.Backup in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenDiskEncryptionSetIdIsPresent.

@Test
void testConvertForInstanceGroupsWhenDiskEncryptionSetIdIsPresent() {
    CreateFreeIpaRequest source = createCreateFreeIpaRequest();
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setAzure(AzureEnvironmentParameters.builder().withResourceEncryptionParameters(AzureResourceEncryptionParameters.builder().withDiskEncryptionSetId("dummyDiskEncryptionSetId").build()).build());
    when(crnService.createCrn(ACCOUNT_ID, CrnResourceDescriptor.FREEIPA)).thenReturn("resourceCrn");
    when(stackAuthenticationConverter.convert(source.getAuthentication())).thenReturn(new StackAuthentication());
    when(instanceGroupConverter.convert(any(), any(), any(), any(), any(), any(), mapCaptorForEncryption.capture())).thenReturn(new InstanceGroup());
    when(telemetryConverter.convert(source.getTelemetry())).thenReturn(new Telemetry());
    when(backupConverter.convert(source.getTelemetry())).thenReturn(new Backup());
    when(entitlementService.internalTenant(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
    when(costTagging.prepareDefaultTags(any())).thenReturn(new HashMap<>());
    Future<String> owner = CompletableFuture.completedFuture("dummyUser");
    underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.AZURE.name());
    assertEquals(mapCaptorForEncryption.getValue().get(DISK_ENCRYPTION_SET_ID), "dummyDiskEncryptionSetId");
}
Also used : StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 25 with Backup

use of com.sequenceiq.freeipa.api.model.Backup in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenEncryptionKeyIsPresentForGcp.

@Test
void testConvertForInstanceGroupsWhenEncryptionKeyIsPresentForGcp() {
    CreateFreeIpaRequest source = createCreateFreeIpaRequest();
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("dummyEncryptionKey").build()).build());
    when(crnService.createCrn(ACCOUNT_ID, CrnResourceDescriptor.FREEIPA)).thenReturn("resourceCrn");
    when(stackAuthenticationConverter.convert(source.getAuthentication())).thenReturn(new StackAuthentication());
    when(instanceGroupConverter.convert(any(), any(), any(), any(), any(), any(), mapCaptorForEncryption.capture())).thenReturn(new InstanceGroup());
    when(telemetryConverter.convert(source.getTelemetry())).thenReturn(new Telemetry());
    when(backupConverter.convert(source.getTelemetry())).thenReturn(new Backup());
    when(entitlementService.internalTenant(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
    when(costTagging.prepareDefaultTags(any())).thenReturn(new HashMap<>());
    Future<String> owner = CompletableFuture.completedFuture("dummyUser");
    underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.GCP.name());
    assertEquals(mapCaptorForEncryption.getValue().get(GCP_KMS_ENCRYPTION_KEY), "dummyEncryptionKey");
}
Also used : StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Aggregations

Backup (com.sequenceiq.freeipa.api.model.Backup)30 Test (org.junit.Test)13 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)12 Test (org.junit.jupiter.api.Test)10 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)7 Logging (com.sequenceiq.common.api.telemetry.model.Logging)7 BackupRequest (com.sequenceiq.common.api.backup.request.BackupRequest)6 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)6 Stack (com.sequenceiq.freeipa.entity.Stack)5 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)4 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)4 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)4 StackAuthentication (com.sequenceiq.freeipa.entity.StackAuthentication)4 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 Network (com.sequenceiq.freeipa.entity.Network)3 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)2