Search in sources :

Example 6 with DnsV1Endpoint

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());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Test(org.junit.jupiter.api.Test)

Example 7 with DnsV1Endpoint

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());
}
Also used : LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) Test(org.junit.Test)

Aggregations

EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)5 Test (org.junit.jupiter.api.Test)5 Environment (com.sequenceiq.environment.environment.domain.Environment)4 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)4 AddDnsZoneForSubnetsRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetsRequest)3 AttachChildEnvironmentRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest)3 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Headers (reactor.bus.Event.Headers)3 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)2 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)2 Test (org.junit.Test)2 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)1 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)1 DetachChildEnvironmentRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.detachchildenv.DetachChildEnvironmentRequest)1