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);
}
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);
}
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;
}
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");
}
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");
}
Aggregations