use of com.sequenceiq.freeipa.entity.Template 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.Template 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.Template in project cloudbreak by hortonworks.
the class InstanceTemplateRequestToTemplateConverterTest method shouldSetAwsDefaultVolumeEncryptionWhenCustomEncryptionKeyArnIsAbsent.
@Test
void shouldSetAwsDefaultVolumeEncryptionWhenCustomEncryptionKeyArnIsAbsent() {
InstanceTemplateRequest source = new InstanceTemplateRequest();
source.setInstanceType(INSTANCE_TYPE);
Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
Json attributes = result.getAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.TRUE);
assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isEqualTo(EncryptionType.DEFAULT.name());
}
use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.
the class InstanceTemplateRequestToTemplateConverterTest method shouldSetEncryptionAtHostPropertyWhenAzureAndEncryptionAtHostEnabled.
@Test
void shouldSetEncryptionAtHostPropertyWhenAzureAndEncryptionAtHostEnabled() {
InstanceTemplateRequest source = new InstanceTemplateRequest();
source.setInstanceType(INSTANCE_TYPE);
when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
Template result = underTest.convert(source, CloudPlatform.AZURE, ACCOUNT_ID, "dummyDiskEncryptionSet", "", "");
Json attributes = result.getAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.<Object>getValue(AzureInstanceTemplate.ENCRYPTION_AT_HOST_ENABLED)).isEqualTo(Boolean.TRUE);
}
use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.
the class InstanceTemplateRequestToTemplateConverterTest method shouldSetDefaultInstanceTypeWhenNotProvided.
@Test
void shouldSetDefaultInstanceTypeWhenNotProvided() {
String defaultInstanceType = "default";
InstanceTemplateRequest source = new InstanceTemplateRequest();
when(defaultInstanceTypeProvider.getForPlatform(CLOUD_PLATFORM.name())).thenReturn(defaultInstanceType);
Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
assertThat(result.getInstanceType()).isEqualTo(defaultInstanceType);
}
Aggregations