use of com.sequenceiq.freeipa.entity.Network in project cloudbreak by hortonworks.
the class FreeIpaConfigServiceTest method testCreateFreeIpaConfigs.
@Test
void testCreateFreeIpaConfigs() {
String backupLocation = "s3://mybucket/test";
Backup backup = new Backup();
backup.setStorageLocation(backupLocation);
backup.setS3(new S3CloudStorageV1Parameters());
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(DOMAIN);
freeIpa.setAdminPassword(PASSWORD);
Stack stack = new Stack();
stack.setCloudPlatform(CloudPlatform.AWS.name());
stack.setBackup(backup);
stack.setEnvironmentCrn("envcrn");
Network network = new Network();
network.setNetworkCidrs(List.of(CIDR));
stack.setNetwork(network);
when(freeIpaService.findByStack(any())).thenReturn(freeIpa);
when(freeIpaClientFactory.getAdminUser()).thenReturn(ADMIN);
when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE);
when(environment.getProperty("freeipa.platform.dnssec.validation.AWS", "true")).thenReturn("true");
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(gatewayConfig.getHostname()).thenReturn(HOSTNAME);
when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
when(proxyConfigDtoService.getByEnvironmentCrn(anyString())).thenReturn(Optional.empty());
Node node = new Node(PRIVATE_IP, null, null, null, HOSTNAME, DOMAIN, (String) null);
Map<String, String> expectedHost = Map.of("ip", PRIVATE_IP, "fqdn", HOSTNAME);
Set<Object> expectedHosts = ImmutableSet.of(expectedHost);
FreeIpaConfigView freeIpaConfigView = underTest.createFreeIpaConfigs(stack, ImmutableSet.of(node));
assertEquals(DOMAIN.toUpperCase(), freeIpaConfigView.getRealm());
assertEquals(DOMAIN, freeIpaConfigView.getDomain());
assertEquals(PASSWORD, freeIpaConfigView.getPassword());
assertEquals(REVERSE_ZONE, freeIpaConfigView.getReverseZones());
assertEquals(ADMIN, freeIpaConfigView.getAdminUser());
assertEquals(HOSTNAME, freeIpaConfigView.getFreeipaToReplicate());
assertEquals(backupLocation, freeIpaConfigView.getBackup().getLocation());
assertEquals(CloudPlatform.AWS.name(), freeIpaConfigView.getBackup().getPlatform());
assertEquals(expectedHosts, freeIpaConfigView.getHosts());
assertEquals(List.of(CIDR), freeIpaConfigView.getCidrBlocks());
}
use of com.sequenceiq.freeipa.entity.Network 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));
}
Aggregations