use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class StackToDescribeFreeIpaResponseConverterTest method convertTest.
@ParameterizedTest(name = "tunnel={0}")
@EnumSource(Tunnel.class)
@NullSource
void convertTest(Tunnel tunnel) {
FreeIpaServerResponse freeIpaServerResponse = new FreeIpaServerResponse();
Stack stack = createStack(tunnel);
ImageEntity image = new ImageEntity();
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(DOMAIN);
UserSyncStatus userSyncStatus = new UserSyncStatus();
when(authenticationResponseConverter.convert(stack.getStackAuthentication())).thenReturn(STACK_AUTHENTICATION_RESPONSE);
when(imageSettingsResponseConverter.convert(image)).thenReturn(IMAGE_SETTINGS_RESPONSE);
when(freeIpaServerResponseConverter.convert(freeIpa)).thenReturn(freeIpaServerResponse);
when(instanceGroupConverter.convert(stack.getInstanceGroups(), true)).thenReturn(INSTANCE_GROUP_RESPONSES);
when(userSyncStatusConverter.convert(userSyncStatus)).thenReturn(USERSYNC_STATUS_RESPONSE);
when(balancedDnsAvailabilityChecker.isBalancedDnsAvailable(stack)).thenReturn(true);
when(stackToAvailabilityStatusConverter.convert(stack)).thenReturn(AvailabilityStatus.AVAILABLE);
DescribeFreeIpaResponse result = underTest.convert(stack, image, freeIpa, Optional.of(userSyncStatus), true);
assertThat(result).returns(NAME, DescribeFreeIpaResponse::getName).returns(ENV_CRN, DescribeFreeIpaResponse::getEnvironmentCrn).returns(RESOURCE_CRN, DescribeFreeIpaResponse::getCrn).returns(CLOUD_PLATFORM, DescribeFreeIpaResponse::getCloudPlatform).returns(STACK_AUTHENTICATION_RESPONSE, DescribeFreeIpaResponse::getAuthentication).returns(IMAGE_SETTINGS_RESPONSE, DescribeFreeIpaResponse::getImage).returns(freeIpaServerResponse, DescribeFreeIpaResponse::getFreeIpa).returns(INSTANCE_GROUP_RESPONSES, DescribeFreeIpaResponse::getInstanceGroups).returns(STATUS, DescribeFreeIpaResponse::getStatus).returns(STATUS_REASON, DescribeFreeIpaResponse::getStatusReason).returns(STATUS_STRING, DescribeFreeIpaResponse::getStatusString).returns(APP_VERSION, DescribeFreeIpaResponse::getAppVersion).returns(VARIANT, DescribeFreeIpaResponse::getVariant).returns(USERSYNC_STATUS_RESPONSE, DescribeFreeIpaResponse::getUserSyncStatus).returns(tunnel, DescribeFreeIpaResponse::getTunnel);
assertThat(freeIpaServerResponse).returns(Set.of(SERVER_IP), FreeIpaServerResponse::getServerIp).returns(FREEIPA_HOST, FreeIpaServerResponse::getFreeIpaHost).returns(GATEWAY_PORT, FreeIpaServerResponse::getFreeIpaPort);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaV1ControllerTest method describeAllInternal.
@Test
void describeAllInternal() {
List<DescribeFreeIpaResponse> response = List.of(new DescribeFreeIpaResponse());
when(describeService.describeAll(anyString(), anyString())).thenReturn(response);
assertEquals(response, underTest.describeAllInternal(ENVIRONMENT_CRN, ACCOUNT_ID));
verify(describeService).describeAll(ENVIRONMENT_CRN, ACCOUNT_ID);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaV1ControllerTest method describeAll.
@Test
void describeAll() {
List<DescribeFreeIpaResponse> response = List.of(new DescribeFreeIpaResponse());
when(describeService.describeAll(anyString(), anyString())).thenReturn(response);
assertEquals(response, underTest.describeAll(ENVIRONMENT_CRN));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeipaService method checkFreeipaRunning.
@Retryable(value = CloudbreakServiceException.class, maxAttempts = 3, backoff = @Backoff(delay = 200))
public boolean checkFreeipaRunning(String envCrn) {
DescribeFreeIpaResponse freeipa = freeipaClientService.getByEnvironmentCrn(envCrn);
if (freeipa == null || freeipa.getAvailabilityStatus() == null || freeipa.getAvailabilityStatus() == AvailabilityStatus.UNKNOWN) {
String message = "Freeipa availability cannot be determined currently.";
LOGGER.info(message);
throw new CloudbreakServiceException(message);
} else if (!freeipa.getAvailabilityStatus().isAvailable()) {
String message = "Freeipa should be in Available state but currently is " + freeipa.getStatus().name();
LOGGER.info(message);
return false;
} else {
return true;
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaPollerServiceTest method testStopAttachedFreeipaInstancesWhenFreeipaStopped.
@Test
void testStopAttachedFreeipaInstancesWhenFreeipaStopped() {
DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
freeipaResponse.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
freeipaResponse.setStatus(Status.STOPPED);
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(0)).stopFreeIpa(ENV_CRN);
}
Aggregations