Search in sources :

Example 21 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldContainErrorsWhenThereAreTooManyInstanceGroups.

@Test
void validateShouldContainErrorsWhenThereAreTooManyInstanceGroups() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(1);
    request.setInstanceGroups(List.of(instanceGroupRequest, instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isTrue();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest 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 23 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest 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)

Example 24 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method createCreateFreeIpaRequest.

private CreateFreeIpaRequest createCreateFreeIpaRequest() {
    CreateFreeIpaRequest source = new CreateFreeIpaRequest();
    source.setEnvironmentCrn("envCrn");
    source.setName("dummyName");
    source.setAuthentication(new StackAuthenticationRequest());
    source.setTelemetry(new TelemetryRequest());
    source.setInstanceGroups(List.of(new InstanceGroupRequest()));
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setDomain("dummyDomain");
    freeIpaServerRequest.setHostname("dummyHostName");
    source.setFreeIpa(freeIpaServerRequest);
    return source;
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)

Example 25 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenAwsNativeIsPresent.

@Test
void testConvertForInstanceGroupsWhenAwsNativeIsPresent() {
    CreateFreeIpaRequest source = new CreateFreeIpaRequest();
    source.setEnvironmentCrn("envCrn");
    source.setName("dummyName");
    source.setVariant("AWS_NATIVE");
    source.setAuthentication(new StackAuthenticationRequest());
    source.setTelemetry(new TelemetryRequest());
    source.setInstanceGroups(List.of(new InstanceGroupRequest()));
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setDomain("dummyDomain");
    freeIpaServerRequest.setHostname("dummyHostName");
    source.setNetwork(new NetworkRequest());
    source.setFreeIpa(freeIpaServerRequest);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build());
    Future<String> owner = CompletableFuture.completedFuture("dummyUser");
    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(networkConverter.convert(any(NetworkRequest.class))).thenReturn(new Network());
    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<>());
    Stack stack = underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.AWS.name());
    assertEquals(stack.getPlatformvariant(), "AWS_NATIVE");
    assertNull(mapCaptorForEncryption.getValue().get(GCP_KMS_ENCRYPTION_KEY));
    assertNull(mapCaptorForEncryption.getValue().get(DISK_ENCRYPTION_SET_ID));
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Stack(com.sequenceiq.freeipa.entity.Stack) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) Network(com.sequenceiq.freeipa.entity.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)23 Test (org.junit.jupiter.api.Test)18 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)5 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)5 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)5 Credential (com.sequenceiq.environment.credential.domain.Credential)5 Environment (com.sequenceiq.environment.environment.domain.Environment)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 Backup (com.sequenceiq.freeipa.api.model.Backup)4 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)3 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)3 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)3 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)3