use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method testImageCatalogAndImageIdParemetersArePopulated.
@Test
public void testImageCatalogAndImageIdParemetersArePopulated() {
EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
environmentDto.getFreeIpaCreation().setImageId(IMAGE_ID);
environmentDto.getFreeIpaCreation().setImageCatalog(IMAGE_CATALOG);
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();
assertEquals(IMAGE_CATALOG, freeIpaRequest.getImage().getCatalog());
assertEquals(IMAGE_ID, freeIpaRequest.getImage().getId());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest 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);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method testFreeIpaImageIdIsPopulatedInCaseOfMissingImageCatalog.
@Test
public void testFreeIpaImageIdIsPopulatedInCaseOfMissingImageCatalog() {
EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
environmentDto.getFreeIpaCreation().setImageId(IMAGE_ID);
environmentDto.getFreeIpaCreation().setImageCatalog(null);
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();
assertNull(freeIpaRequest.getImage().getCatalog());
assertEquals(IMAGE_ID, freeIpaRequest.getImage().getId());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method testRebuild.
@Test
public void testRebuild() throws Exception {
Stack stack = createStack(Status.DELETE_COMPLETED, List.of(InstanceStatus.TERMINATED, InstanceStatus.TERMINATED), 2);
CreateFreeIpaRequest createFreeIpaRequest = new CreateFreeIpaRequest();
DescribeFreeIpaResponse response = new DescribeFreeIpaResponse();
when(stackService.getByCrnAndAccountIdEvenIfTerminated(ENVIRONMENT_ID1, ACCOUNT_ID, FREEIPA_CRN)).thenReturn(stack);
when(stackService.findByEnvironmentCrnAndAccountId(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(Optional.empty());
when(stackToCreateFreeIpaRequestConverter.convert(eq(stack))).thenReturn(createFreeIpaRequest);
when(freeIpaCreationService.launchFreeIpa(eq(createFreeIpaRequest), eq(ACCOUNT_ID))).thenReturn(response);
when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
RebuildRequest rebuildRequest = new RebuildRequest();
rebuildRequest.setEnvironmentCrn(ENVIRONMENT_ID1);
rebuildRequest.setSourceCrn(FREEIPA_CRN);
assertEquals(response, underTest.rebuild(ACCOUNT_ID, rebuildRequest));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method setImage.
private void setImage(EnvironmentDto environment, CreateFreeIpaRequest createFreeIpaRequest) {
if (environment.getFreeIpaCreation() != null) {
String imageCatalog = environment.getFreeIpaCreation().getImageCatalog();
String imageId = environment.getFreeIpaCreation().getImageId();
if (!Strings.isNullOrEmpty(imageId)) {
LOGGER.info("FreeIPA creation with a pre-defined image catalog and image id: '{}', '{}'", imageCatalog, imageId);
ImageSettingsRequest imageSettings = new ImageSettingsRequest();
imageSettings.setCatalog(imageCatalog);
imageSettings.setId(imageId);
createFreeIpaRequest.setImage(imageSettings);
} else {
LOGGER.info("FreeIPA creation without pre-defined image settings. FreeIpa serivce is going to handle default settings.");
}
}
}
Aggregations