Search in sources :

Example 11 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class FreeIpaConverterTest method testConvertWithImage.

@Test
public void testConvertWithImage() {
    // GIVEN
    AttachedFreeIpaRequest request = new AttachedFreeIpaRequest();
    request.setCreate(true);
    request.setImage(aFreeIpaImage(IMAGE_CATALOG, IMAGE_ID));
    request.setEnableMultiAz(true);
    // WHEN
    when(entitlementService.awsNativeFreeIpaEnabled(anyString())).thenReturn(true);
    FreeIpaCreationDto result = underTest.convert(request, "id", CloudConstants.AWS);
    // THEN
    assertEquals(IMAGE_CATALOG, result.getImageCatalog());
    assertEquals(IMAGE_ID, result.getImageId());
}
Also used : AttachedFreeIpaRequest(com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) Test(org.junit.jupiter.api.Test)

Example 12 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class FreeIpaConverterTest method testConvertWithDefaults.

@Test
public void testConvertWithDefaults() {
    // GIVEN
    FreeIpaCreationDto request = FreeIpaCreationDto.builder().build();
    // WHEN
    FreeIpaResponse result = underTest.convert(request);
    // THEN
    assertNotNull(result);
    assertNotNull(result.getInstanceCountByGroup());
    assertEquals(1, result.getInstanceCountByGroup());
    assertNull(result.getAws());
    assertNull(result.getImage());
}
Also used : FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 13 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method shouldValidateFreeIpaCreation.

@ParameterizedTest
@MethodSource("freeIpaCreationArguments")
void shouldValidateFreeIpaCreation(int instanceCountByGroup, int spotPercentage, boolean valid) {
    FreeIpaCreationDto freeIpaCreationDto = FreeIpaCreationDto.builder().withInstanceCountByGroup(instanceCountByGroup).withAws(FreeIpaCreationAwsParametersDto.builder().withSpot(FreeIpaCreationAwsSpotParametersDto.builder().withPercentage(spotPercentage).build()).build()).build();
    ValidationResult validationResult = underTest.validateFreeIpaCreation(freeIpaCreationDto);
    assertEquals(!valid, validationResult.hasError());
}
Also used : FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class EnvironmentApiConverterTest method testInitCreationDto.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE", "GCP" })
void testInitCreationDto(CloudPlatform cloudPlatform) {
    EnvironmentRequest request = createEnvironmentRequest(cloudPlatform);
    FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
    EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
    AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
    Features features = mock(Features.class);
    NetworkDto networkDto = mock(NetworkDto.class);
    when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(cloudPlatform.name());
    when(freeIpaConverter.convert(request.getFreeIpa(), "test-aws", cloudPlatform.name())).thenReturn(freeIpaCreationDto);
    when(accountTelemetry.getFeatures()).thenReturn(features);
    when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
    when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
    when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
    when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
    EnvironmentCreationDto actual = testInitCreationDto(request);
    assertEquals("test-aws", actual.getAccountId());
    assertEquals(USER_CRN, actual.getCreator());
    assertEquals(request.getName(), actual.getName());
    assertEquals(request.getDescription(), actual.getDescription());
    assertEquals(request.getCredentialName(), actual.getCredential().getCredentialName());
    assertEquals(request, actual.getCredential());
    assertEquals(freeIpaCreationDto, actual.getFreeIpaCreation());
    assertLocation(request.getLocation(), actual.getLocation());
    assertEquals(environmentTelemetry, actual.getTelemetry());
    assertEquals(1, actual.getRegions().size());
    assertAuthentication(request.getAuthentication(), actual.getAuthentication());
    assertEquals(request.getAdminGroupName(), actual.getAdminGroupName());
    assertEquals(request.getTags(), actual.getTags());
    assertExperimentalFeatures(request, actual.getExperimentalFeatures());
    assertParameters(request, actual.getParameters(), cloudPlatform);
    assertEquals(request.getProxyConfigName(), actual.getProxyConfigName());
    assertEquals(networkDto, actual.getNetwork());
    assertSecurityAccess(request.getSecurityAccess(), actual.getSecurityAccess());
    verify(credentialService).getCloudPlatformByCredential(anyString(), anyString(), any());
    verify(freeIpaConverter).convert(request.getFreeIpa(), "test-aws", cloudPlatform.name());
    verify(accountTelemetry).getFeatures();
    verify(accountTelemetryService).getOrDefault(any());
    verify(telemetryApiConverter).convert(eq(request.getTelemetry()), any(), anyString());
    verify(tunnelConverter).convert(request.getTunnel());
    verify(networkRequestToDtoConverter).convert(request.getNetwork());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) EnvironmentRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest) Features(com.sequenceiq.common.api.telemetry.model.Features) ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) EnvironmentCreationDto(com.sequenceiq.environment.environment.dto.EnvironmentCreationDto) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with FreeIpaCreationDto

use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.

the class EnvironmentApiConverterTest method testGcpResourceEncryptionParametersAndGcpRequest.

@Test
void testGcpResourceEncryptionParametersAndGcpRequest() {
    EnvironmentRequest request = createEnvironmentRequest(GCP);
    request.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("dummy-encryption-key").build()).build());
    FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
    EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
    EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
    AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
    Features features = mock(Features.class);
    NetworkDto networkDto = mock(NetworkDto.class);
    when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(GCP.name());
    when(freeIpaConverter.convert(request.getFreeIpa(), "id", CloudConstants.AWS)).thenReturn(freeIpaCreationDto);
    when(accountTelemetry.getFeatures()).thenReturn(features);
    when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
    when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
    when(backupConverter.convert(eq(request.getBackup()))).thenReturn(environmentBackup);
    when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
    when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
    EnvironmentCreationDto actual = testInitCreationDto(request);
    assertEquals("dummy-encryption-key", actual.getParameters().getGcpParametersDto().getGcpResourceEncryptionParametersDto().getEncryptionKey());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) EnvironmentBackup(com.sequenceiq.environment.environment.dto.EnvironmentBackup) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) EnvironmentRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest) Features(com.sequenceiq.common.api.telemetry.model.Features) ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) EnvironmentCreationDto(com.sequenceiq.environment.environment.dto.EnvironmentCreationDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)21 Test (org.junit.jupiter.api.Test)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Features (com.sequenceiq.common.api.telemetry.model.Features)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)7 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)7 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)7 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)6 AttachedFreeIpaRequest (com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest)4 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)4 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 FreeIpaImageRequest (com.sequenceiq.environment.api.v1.environment.model.request.FreeIpaImageRequest)1 FreeIpaCreationAwsParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto)1 FreeIpaCreationAwsSpotParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto)1 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)1