use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIPAEndpointManagementServiceTest method testRegisterLoadBalancerWithIP.
@Test
public void testRegisterLoadBalancerWithIP() {
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setType(LoadBalancerType.PUBLIC);
loadBalancer.setIp(LB_IP);
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<AddDnsARecordRequest> requestCaptor = ArgumentCaptor.forClass(AddDnsARecordRequest.class);
verify(dnsV1Endpoint, times(1)).addDnsARecordInternal(any(), requestCaptor.capture());
assertEquals(LB_IP, requestCaptor.getValue().getIp());
assertEquals(LB_ENDPOINT, requestCaptor.getValue().getHostname());
}
use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method shouldAttachFreeIpaInCaseOfChildEnvironment.
@Test
public void shouldAttachFreeIpaInCaseOfChildEnvironment() throws Exception {
DescribeFreeIpaResponse describeFreeIpaResponse = mock(DescribeFreeIpaResponse.class);
EnvironmentDto environmentDto = aYarnEnvironmentDtoWithParentEnvironment();
Environment environment = anEnvironmentWithParent();
ArgumentCaptor<AddDnsZoneForSubnetsRequest> addDnsZoneForSubnetsRequestArgumentCaptor = ArgumentCaptor.forClass(AddDnsZoneForSubnetsRequest.class);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(freeIpaService.describe(PARENT_ENVIRONMENT_CRN)).thenReturn(Optional.of(describeFreeIpaResponse));
victim.accept(new Event<>(environmentDto));
ArgumentCaptor<AttachChildEnvironmentRequest> attachChildEnvironmentRequestArgumentCaptor = ArgumentCaptor.forClass(AttachChildEnvironmentRequest.class);
verify(dnsV1Endpoint).addDnsZoneForSubnets(addDnsZoneForSubnetsRequestArgumentCaptor.capture());
verify(freeIpaService).attachChildEnvironment(attachChildEnvironmentRequestArgumentCaptor.capture());
verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Headers.class));
assertEquals(PARENT_ENVIRONMENT_CRN, addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getEnvironmentCrn());
assertEquals(Collections.singletonList(YARN_NETWORK_CIDR), addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getSubnets());
assertEquals(ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getChildEnvironmentCrn());
assertEquals(PARENT_ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getParentEnvironmentCrn());
}
use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method shouldNotAttachFreeIpaInCaseOfNonSupportedCloudPlatform.
@Test
public void shouldNotAttachFreeIpaInCaseOfNonSupportedCloudPlatform() throws Exception {
EnvironmentDto environmentDto = aNonYarnEnvironmentDtoWithParentEnvironment();
Environment environment = anEnvironmentWithParent();
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
victim.accept(new Event<>(environmentDto));
verify(dnsV1Endpoint, never()).addDnsZoneForSubnets(any(AddDnsZoneForSubnetsRequest.class));
verify(freeIpaService, never()).attachChildEnvironment(any(AttachChildEnvironmentRequest.class));
verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Headers.class));
}
use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method shouldNotAttachInCaseOfMissingFreeIpa.
@Test
public void shouldNotAttachInCaseOfMissingFreeIpa() throws Exception {
EnvironmentDto environmentDto = aYarnEnvironmentDtoWithParentEnvironment();
Environment environment = anEnvironmentWithParent();
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(freeIpaService.describe(PARENT_ENVIRONMENT_CRN)).thenReturn(Optional.empty());
victim.accept(new Event<>(environmentDto));
verify(dnsV1Endpoint, never()).addDnsZoneForSubnets(any(AddDnsZoneForSubnetsRequest.class));
verify(freeIpaService, never()).attachChildEnvironment(any(AttachChildEnvironmentRequest.class));
verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Headers.class));
}
use of com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint in project cloudbreak by hortonworks.
the class FreeIpaDeletionHandlerTest method shouldDetachChildEnvironmentIfParentExists.
@Test
public void shouldDetachChildEnvironmentIfParentExists() throws Exception {
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setId(CHILD_ENVIRONMENT_ID);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(environmentDto).withForceDelete(true).withId(CHILD_ENVIRONMENT_ID).build();
when(environmentService.findEnvironmentById(CHILD_ENVIRONMENT_ID)).thenReturn(of(anEnvironmentWithParent(CHILD_ENVIRONMENT_ID)));
when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(of(new DescribeFreeIpaResponse()));
victim.accept(new Event<>(environmentDeletionDto));
ArgumentCaptor<DetachChildEnvironmentRequest> detachChildEnvironmentRequestArgumentCaptor = ArgumentCaptor.forClass(DetachChildEnvironmentRequest.class);
verify(freeIpaService).detachChildEnvironment(detachChildEnvironmentRequestArgumentCaptor.capture());
verifyNoMoreInteractions(freeIpaService);
verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Event.Headers.class));
verify(dnsV1Endpoint).deleteDnsZoneBySubnet(eq(PARENT_ENVIRONMENT_CRN), any());
assertEquals(PARENT_ENVIRONMENT_CRN, detachChildEnvironmentRequestArgumentCaptor.getValue().getParentEnvironmentCrn());
assertEquals(ENVIRONMENT_CRN, detachChildEnvironmentRequestArgumentCaptor.getValue().getChildEnvironmentCrn());
}
Aggregations