Search in sources :

Example 6 with Network

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());
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Backup(com.sequenceiq.freeipa.api.model.Backup) Network(com.sequenceiq.freeipa.entity.Network) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with Network

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

Network (com.sequenceiq.freeipa.entity.Network)7 Stack (com.sequenceiq.freeipa.entity.Stack)4 Json (com.sequenceiq.cloudbreak.common.json.Json)3 Backup (com.sequenceiq.freeipa.api.model.Backup)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 Test (org.junit.jupiter.api.Test)3 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)2 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)2 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)2 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)2 StackAuthenticationRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest)2 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)2 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)2 StackAuthentication (com.sequenceiq.freeipa.entity.StackAuthentication)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)1