Search in sources :

Example 51 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestTemplateConversion.

@Test
void convertTestTemplateConversion() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(MOCK.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    InstanceTemplateRequest instanceTemplateRequest = mock(InstanceTemplateRequest.class);
    request.setInstanceTemplateRequest(instanceTemplateRequest);
    Template template = mock(Template.class);
    when(templateConverter.convert(instanceTemplateRequest, MOCK, ACCOUNT_ID, "dummyDiskEncryptionSetId", "encryptionKey", "awsEncryptionKeyArn")).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap("dummyDiskEncryptionSetId", "encryptionKey", "awsEncryptionKeyArn"));
    assertThat(result).isNotNull();
    assertThat(result.getTemplate()).isSameAs(template);
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 52 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestTemplateConversionWithAwsEncryptionKey.

@Test
void convertTestTemplateConversionWithAwsEncryptionKey() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(AWS.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    InstanceTemplateRequest instanceTemplateRequest = mock(InstanceTemplateRequest.class);
    request.setInstanceTemplateRequest(instanceTemplateRequest);
    Template template = new Template();
    Map<String, Object> json = new HashMap<>();
    json.put(AwsInstanceTemplate.VOLUME_ENCRYPTION_KEY_ID, "dummyAwsDiskEncryptionKeyArn");
    json.put(AwsInstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.CUSTOM);
    template.setAttributes(new Json(json));
    when(templateConverter.convert(instanceTemplateRequest, AWS, ACCOUNT_ID, null, null, "dummyAwsDiskEncryptionKeyArn")).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap(null, null, "dummyAwsDiskEncryptionKeyArn"));
    assertThat(result).isNotNull();
    assertThat(result.getTemplate()).isSameAs(template);
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) HashMap(java.util.HashMap) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Json(com.sequenceiq.cloudbreak.common.json.Json) Stack(com.sequenceiq.freeipa.entity.Stack) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) 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)

Example 53 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceGroupToInstanceGroupDetailsConverterTest method createInstanceGroup.

private InstanceGroup createInstanceGroup() {
    InstanceGroup instanceGroup = new InstanceGroup();
    Template template = new Template();
    Map<String, Object> attributes = Map.of("encrypted", Boolean.TRUE, "everything-else", Boolean.TRUE);
    template.setAttributes(new Json(attributes));
    instanceGroup.setTemplate(template);
    return instanceGroup;
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template)

Example 54 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup 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 55 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup 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

InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)60 Stack (com.sequenceiq.freeipa.entity.Stack)32 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)31 Test (org.junit.jupiter.api.Test)30 Template (com.sequenceiq.freeipa.entity.Template)18 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)11 Json (com.sequenceiq.cloudbreak.common.json.Json)10 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)10 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)9 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 InstanceGroupNetwork (com.sequenceiq.freeipa.entity.InstanceGroupNetwork)9 HashSet (java.util.HashSet)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)7 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)6 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 HashMap (java.util.HashMap)6 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)5