use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest 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.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest in project cloudbreak by hortonworks.
the class FreeIpaDetachChildEnvironmentAction method convertRequest.
private DetachChildEnvironmentRequest convertRequest(AttachChildEnvironmentRequest attachChildEnvironmentRequest) {
DetachChildEnvironmentRequest detachChildEnvironmentRequest = new DetachChildEnvironmentRequest();
detachChildEnvironmentRequest.setParentEnvironmentCrn(attachChildEnvironmentRequest.getParentEnvironmentCrn());
detachChildEnvironmentRequest.setChildEnvironmentCrn(attachChildEnvironmentRequest.getChildEnvironmentCrn());
return detachChildEnvironmentRequest;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest in project cloudbreak by hortonworks.
the class FreeIpaV1ControllerTest method attachChildEnvironment.
@Test
void attachChildEnvironment() {
AttachChildEnvironmentRequest attachChildEnvironmentRequest = new AttachChildEnvironmentRequest();
when(attachChildEnvironmentRequestValidator.validate(attachChildEnvironmentRequest)).thenReturn(ValidationResult.builder().build());
underTest.attachChildEnvironment(attachChildEnvironmentRequest);
verify(childEnvironmentService, times(1)).attachChildEnvironment(attachChildEnvironmentRequest, ACCOUNT_ID);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method attachParentFreeIpa.
private void attachParentFreeIpa(EnvironmentDto environmentDto) throws Exception {
if (enabledChildPlatforms.stream().anyMatch(p -> p.equalsIgnoreCase(environmentDto.getCloudPlatform()))) {
String parentEnvironmentCrn = environmentDto.getParentEnvironmentCrn();
Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(parentEnvironmentCrn);
if (freeIpa.isPresent()) {
LOGGER.info("Using FreeIpa of parent environment '{}' .", parentEnvironmentCrn);
AttachChildEnvironmentRequest attachChildEnvironmentRequest = new AttachChildEnvironmentRequest();
attachChildEnvironmentRequest.setChildEnvironmentCrn(environmentDto.getResourceCrn());
attachChildEnvironmentRequest.setParentEnvironmentCrn(parentEnvironmentCrn);
freeIpaService.attachChildEnvironment(attachChildEnvironmentRequest);
AddDnsZoneForSubnetsRequest addDnsZoneForSubnetsRequest = new AddDnsZoneForSubnetsRequest();
addDnsZoneForSubnetsRequest.setEnvironmentCrn(parentEnvironmentCrn);
addDnsZoneForSubnetsRequest.setSubnets(getSubnetCidrs(environmentDto));
dnsV1Endpoint.addDnsZoneForSubnets(addDnsZoneForSubnetsRequest);
}
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest in project cloudbreak by hortonworks.
the class ChildEnvironmentServiceTest method attachChildEnvironment.
@Test
void attachChildEnvironment() {
AttachChildEnvironmentRequest request = new AttachChildEnvironmentRequest();
request.setParentEnvironmentCrn(ENVIRONMENT_CRN);
request.setChildEnvironmentCrn(CHILD_ENVIRONMENT_CRN);
Stack stack = new Stack();
when(stackService.getByOwnEnvironmentCrnAndAccountIdWithLists(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
underTest.attachChildEnvironment(request, ACCOUNT_ID);
ArgumentCaptor<ChildEnvironment> childEnvironmentArgumentCaptor = ArgumentCaptor.forClass(ChildEnvironment.class);
verify(repository).save(childEnvironmentArgumentCaptor.capture());
ChildEnvironment childEnvironment = childEnvironmentArgumentCaptor.getValue();
Assertions.assertThat(childEnvironment).returns(CHILD_ENVIRONMENT_CRN, ChildEnvironment::getEnvironmentCrn).returns(stack, ChildEnvironment::getStack);
}
Aggregations