Search in sources :

Example 6 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordAddSameDomain.

@Test
public void testCnameRecordAddSameDomain() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    request.setDnsZone(DOMAIN);
    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(), request.getTargetFqdn());
}
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)

Example 7 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class FreeIPAEndpointManagementServiceTest method testRegisterLoadBalancerWithDNS.

@Test
public void testRegisterLoadBalancerWithDNS() {
    LoadBalancer loadBalancer = new LoadBalancer();
    loadBalancer.setType(LoadBalancerType.PUBLIC);
    loadBalancer.setDns(LB_DNS);
    loadBalancer.setEndpoint(LB_ENDPOINT);
    when(loadBalancerPersistenceService.findByStackId(any())).thenReturn(Set.of(loadBalancer));
    when(loadBalancerConfigService.selectLoadBalancerForFrontend(any(), any())).thenReturn(Optional.of(loadBalancer));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.registerLoadBalancerDomainWithFreeIPA(stack));
    ArgumentCaptor<AddDnsCnameRecordRequest> requestCaptor = ArgumentCaptor.forClass(AddDnsCnameRecordRequest.class);
    verify(dnsV1Endpoint, times(1)).addDnsCnameRecordInternal(any(), requestCaptor.capture());
    assertEquals(LB_DNS + '.', requestCaptor.getValue().getTargetFqdn());
    assertEquals(LB_ENDPOINT, requestCaptor.getValue().getCname());
}
Also used : LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) Test(org.junit.Test)

Example 8 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordExists.

@Test
public void testCnameRecordExists() 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.setCnamerecord(List.of(request.getTargetFqdn()));
    dnsRecord.setIdnsname(request.getCname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getCname())).thenReturn(dnsRecord);
    underTest.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient, times(0)).addDnsCnameRecord(DOMAIN, request.getCname(), request.getTargetFqdn());
}
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 9 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordAddDifferentDomainExists.

@Test
public void testCnameRecordAddDifferentDomainExists() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    request.setDnsZone(DOMAIN2);
    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);
    when(freeIpaClient.findAllDnsZone()).thenReturn(createDnsZones(DOMAIN, DOMAIN2));
    underTest.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsCnameRecord(request.getDnsZone(), request.getCname(), request.getTargetFqdn());
}
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)

Example 10 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest 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)

Aggregations

AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)13 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)10 Stack (com.sequenceiq.freeipa.entity.Stack)10 Test (org.junit.jupiter.api.Test)10 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)3 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)2 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1