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