Search in sources :

Example 56 with FreeIpa

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

the class DnsRecordServiceTest method createFreeIpa.

private FreeIpa createFreeIpa() {
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain(DOMAIN);
    return freeIpa;
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa)

Example 57 with FreeIpa

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

the class DnsRecordServiceTest method testCnameRecordExistsNotCname.

@Test
public void testCnameRecordExistsNotCname() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setPtrrecord(List.of("asdf"));
    dnsRecord.setIdnsname(request.getCname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getCname())).thenReturn(dnsRecord);
    Assertions.assertThrows(DnsRecordConflictException.class, () -> underTest.addDnsCnameRecord(ACCOUNT_ID, request));
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 58 with FreeIpa

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

the class FreeIpaConfigServiceTest method testCcmV2Tunnel.

@ParameterizedTest(name = "{0}")
@MethodSource("ccmv2Scenarios")
void testCcmV2Tunnel(Tunnel tunnel, boolean expectedCcmv2Enabled, boolean expectedCcmV2JumpgateEnabled) {
    Stack stack = new Stack();
    stack.setTunnel(tunnel);
    Network network = new Network();
    network.setNetworkCidrs(List.of(CIDR));
    stack.setNetwork(network);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain(DOMAIN);
    when(freeIpaService.findByStack(any())).thenReturn(freeIpa);
    when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE);
    when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    when(gatewayConfig.getHostname()).thenReturn(HOSTNAME);
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
    FreeIpaConfigView freeIpaConfigView = underTest.createFreeIpaConfigs(stack, Set.of());
    assertEquals(expectedCcmv2Enabled, freeIpaConfigView.isCcmv2Enabled());
    assertEquals(expectedCcmV2JumpgateEnabled, freeIpaConfigView.isCcmv2JumpgateEnabled());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Network(com.sequenceiq.freeipa.entity.Network) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 59 with FreeIpa

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

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

the class DnsRecordServiceTest method testCnameRecordAddWithoutTrailingDot.

@Test
public void testCnameRecordAddWithoutTrailingDot() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn("example2.com");
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    underTest.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsCnameRecord(DOMAIN, request.getCname(), TARGET_FQDN);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)75 Stack (com.sequenceiq.freeipa.entity.Stack)62 Test (org.junit.jupiter.api.Test)50 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)10 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)10 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)10 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)8 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)7 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)6 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)6 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)6 Set (java.util.Set)6 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)5 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)5 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 Optional (java.util.Optional)5