Search in sources :

Example 36 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaPollerServiceTest method testSyncUsersWhenFreeIpaStopped.

@Test
void testSyncUsersWhenFreeIpaStopped() {
    DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
    freeipaResponse.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    freeipaResponse.setStatus(Status.STOPPED);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
    underTest.waitForSynchronizeUsers(ENV_ID, ENV_CRN);
    verify(freeIpaService, never()).synchronizeAllUsersInEnvironment(ENV_CRN);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 37 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaPollerServiceTest method testStartAttachedFreeipaInstancesWhenFreeipaAvailable.

@Test
void testStartAttachedFreeipaInstancesWhenFreeipaAvailable() {
    DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
    freeipaResponse.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipaResponse.setStatus(Status.AVAILABLE);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
    when(freeipaPollerProvider.startPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish);
    underTest.startAttachedFreeipaInstances(ENV_ID, ENV_CRN);
    verify(freeIpaService, times(0)).startFreeIpa(ENV_CRN);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) AttemptResults(com.dyngr.core.AttemptResults) Test(org.junit.jupiter.api.Test)

Example 38 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaPollerServiceTest method testStopAttachedFreeipaInstancesWhenFreeipaAvailable.

@Test
void testStopAttachedFreeipaInstancesWhenFreeipaAvailable() {
    DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
    freeipaResponse.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipaResponse.setStatus(Status.AVAILABLE);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
    when(freeipaPollerProvider.stopPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish);
    underTest.stopAttachedFreeipaInstances(ENV_ID, ENV_CRN);
    verify(freeIpaService, times(1)).stopFreeIpa(ENV_CRN);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) AttemptResults(com.dyngr.core.AttemptResults) Test(org.junit.jupiter.api.Test)

Example 39 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaServiceTest method internalDescribeFreeipaNotFoundTest.

@Test
void internalDescribeFreeipaNotFoundTest() {
    ExceptionResponse exceptionResponse = new ExceptionResponse("Freeipa not found");
    final Response response = mock(Response.class);
    Mockito.when(response.readEntity(Mockito.any(Class.class))).thenReturn(exceptionResponse);
    NotFoundException notFoundException = mock(NotFoundException.class);
    when(notFoundException.getResponse()).thenReturn(response);
    when(freeIpaV1Endpoint.describeInternal(eq(ENVCRN), eq("1111"))).thenThrow(notFoundException);
    Optional<DescribeFreeIpaResponse> describeFreeIpaResponse = underTest.internalDescribe(ENVCRN, "1111");
    assertThat(describeFreeIpaResponse.isEmpty()).isEqualTo(true);
}
Also used : ExceptionResponse(com.sequenceiq.cloudbreak.common.exception.ExceptionResponse) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Response(javax.ws.rs.core.Response) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) ExceptionResponse(com.sequenceiq.cloudbreak.common.exception.ExceptionResponse) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 40 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class EnvironmentSyncServiceTest method getFreeipaResponse.

private static DescribeFreeIpaResponse getFreeipaResponse(Status status) {
    DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
    freeIpaResponse.setStatus(status);
    return freeIpaResponse;
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)

Aggregations

DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)60 Test (org.junit.jupiter.api.Test)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)8 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)7 InstanceGroupResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)6 AttemptResults (com.dyngr.core.AttemptResults)5 Stack (com.sequenceiq.freeipa.entity.Stack)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)3 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)3 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)3 InstanceMetaDataResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse)3 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 Environment (com.sequenceiq.environment.environment.domain.Environment)2