use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIpaDeletionHandlerTest method shouldNotDeleteDnsZoneWhenSiblingsExist.
@Test
public void shouldNotDeleteDnsZoneWhenSiblingsExist() throws Exception {
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setId(CHILD_ENVIRONMENT_ID);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(environmentDto).withForceDelete(true).withId(CHILD_ENVIRONMENT_ID).build();
Environment environment = anEnvironmentWithParent(CHILD_ENVIRONMENT_ID);
when(environmentService.findEnvironmentById(CHILD_ENVIRONMENT_ID)).thenReturn(of(environment));
when(environmentService.findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(anyString(), eq(PARENT_ENVIRONMENT_ID))).thenReturn(List.of(environment, anEnvironmentWithParent(ANOTHER_CHILD_ENVIRONMENT_ID)));
when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(of(new DescribeFreeIpaResponse()));
victim.accept(new Event<>(environmentDeletionDto));
verify(dnsV1Endpoint, never()).deleteDnsZoneBySubnet(eq(PARENT_ENVIRONMENT_CRN), any());
}
use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint 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());
}
Aggregations