Search in sources :

Example 1 with FreeIpaService

use of com.sequenceiq.environment.environment.service.freeipa.FreeIpaService in project cloudbreak by hortonworks.

the class FreeIpaCreationHandlerTest method testFreeIpaInstanceTypeIsPopulatedIfProvided.

@Test
public void testFreeIpaInstanceTypeIsPopulatedIfProvided() {
    EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
    environmentDto.getFreeIpaCreation().setInstanceType(INSTANCE_TYPE);
    environmentDto.setCredential(new Credential());
    Environment environment = new Environment();
    environment.setCreateFreeIpa(true);
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build();
    when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
    when(supportedPlatforms.supportedPlatformForFreeIpa(environment.getCloudPlatform())).thenReturn(true);
    when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(Optional.empty());
    when(connectors.getDefault(any())).thenReturn(mock(CloudConnector.class));
    when(freeIpaPollingService.pollWithTimeout(any(FreeIpaCreationRetrievalTask.class), any(FreeIpaPollerObject.class), anyLong(), anyInt(), anyInt())).thenReturn(extendedPollingResult);
    victim.accept(new Event<>(environmentDto));
    ArgumentCaptor<CreateFreeIpaRequest> freeIpaRequestCaptor = ArgumentCaptor.forClass(CreateFreeIpaRequest.class);
    verify(freeIpaService).create(freeIpaRequestCaptor.capture());
    CreateFreeIpaRequest freeIpaRequest = freeIpaRequestCaptor.getValue();
    assertThat(freeIpaRequest.getInstanceGroups()).extracting(ig -> ig.getInstanceTemplate().getInstanceType()).containsOnly(INSTANCE_TYPE);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Environment(com.sequenceiq.environment.environment.domain.Environment) AddDnsZoneForSubnetsRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetsRequest) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) DnsV1Endpoint(com.sequenceiq.freeipa.api.v1.dns.DnsV1Endpoint) AttachChildEnvironmentRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) Map(java.util.Map) Region(com.sequenceiq.environment.environment.domain.Region) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) BackupConverter(com.sequenceiq.environment.environment.v1.converter.BackupConverter) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) EventSender(com.sequenceiq.flow.reactor.api.event.EventSender) Set(java.util.Set) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) EventBus(reactor.bus.EventBus) FreeIpaService(com.sequenceiq.environment.environment.service.freeipa.FreeIpaService) Test(org.junit.jupiter.api.Test) PollingService(com.sequenceiq.cloudbreak.polling.PollingService) FreeIpaCreationAwsParametersDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto) SupportedPlatforms(com.sequenceiq.environment.configuration.SupportedPlatforms) EnvironmentTags(com.sequenceiq.environment.environment.domain.EnvironmentTags) Optional(java.util.Optional) PollingResult(com.sequenceiq.cloudbreak.polling.PollingResult) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Mock(org.mockito.Mock) Credential(com.sequenceiq.environment.credential.domain.Credential) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) EnumSource(org.junit.jupiter.params.provider.EnumSource) AuthenticationDto(com.sequenceiq.environment.environment.dto.AuthenticationDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ArgumentCaptor(org.mockito.ArgumentCaptor) Event(reactor.bus.Event) FreeIpaCreationAwsSpotParametersDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto) Mode(org.junit.jupiter.params.provider.EnumSource.Mode) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Headers(reactor.bus.Event.Headers) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) AwsInstanceTemplateParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.AwsInstanceTemplateParameters) TelemetryApiConverter(com.sequenceiq.environment.environment.v1.converter.TelemetryApiConverter) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) EnvironmentService(com.sequenceiq.environment.environment.service.EnvironmentService) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) Collections(java.util.Collections) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Credential(com.sequenceiq.environment.credential.domain.Credential) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)1 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 CloudPlatformConnectors (com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)1 PollingResult (com.sequenceiq.cloudbreak.polling.PollingResult)1 PollingService (com.sequenceiq.cloudbreak.polling.PollingService)1 SupportedPlatforms (com.sequenceiq.environment.configuration.SupportedPlatforms)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 Environment (com.sequenceiq.environment.environment.domain.Environment)1 EnvironmentTags (com.sequenceiq.environment.environment.domain.EnvironmentTags)1 Region (com.sequenceiq.environment.environment.domain.Region)1 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 FreeIpaCreationAwsParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto)1 FreeIpaCreationAwsSpotParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto)1 FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)1 EnvironmentService (com.sequenceiq.environment.environment.service.EnvironmentService)1 FreeIpaService (com.sequenceiq.environment.environment.service.freeipa.FreeIpaService)1 BackupConverter (com.sequenceiq.environment.environment.v1.converter.BackupConverter)1