use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest in project cloudbreak by hortonworks.
the class FreeIpaRebuildAction method action.
public FreeIpaTestDto action(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient client) throws Exception {
Log.when(LOGGER, format(" FreeIPA CRN: %s", testDto.getRequest().getEnvironmentCrn()));
RebuildRequest request = new RebuildRequest();
request.setEnvironmentCrn(testDto.getRequest().getEnvironmentCrn());
request.setSourceCrn(testDto.getCrn());
Log.whenJson(LOGGER, format(" FreeIPA rebuild request: %n"), request);
testDto.setResponse(client.getDefaultClient().getFreeIpaV1Endpoint().rebuild(request));
Log.whenJson(LOGGER, format(" FreeIPA rebuilt successfully:%n"), testDto.getResponse());
Log.when(LOGGER, format(" FreeIPA CRN: %s", testDto.getResponse().getCrn()));
return testDto;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest 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.rebuild.RebuildRequest in project cloudbreak by hortonworks.
the class FreeIpaV1ControllerTest method rebuild.
@Test
void rebuild() {
when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID);
RebuildRequest request = new RebuildRequest();
underTest.rebuild(request);
verify(repairInstancesService, times(1)).rebuild(crnService.getCurrentAccountId(), request);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method testRebuildThrowsWhenSourceStackIsRunning.
@Test
public void testRebuildThrowsWhenSourceStackIsRunning() throws Exception {
Stack stack = createStack(Status.AVAILABLE, List.of(InstanceStatus.CREATED, InstanceStatus.CREATED), 2);
when(stackService.getByCrnAndAccountIdEvenIfTerminated(ENVIRONMENT_ID1, ACCOUNT_ID, FREEIPA_CRN)).thenReturn(stack);
when(stackService.findByEnvironmentCrnAndAccountId(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(Optional.of(stack));
when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
RebuildRequest rebuildRequest = new RebuildRequest();
rebuildRequest.setEnvironmentCrn(ENVIRONMENT_ID1);
rebuildRequest.setSourceCrn(FREEIPA_CRN);
assertThrows(BadRequestException.class, () -> underTest.rebuild(ACCOUNT_ID, rebuildRequest));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method testRebuildThrowsWhenEntitlementIsDisabled.
@Test
public void testRebuildThrowsWhenEntitlementIsDisabled() throws Exception {
when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(false);
RebuildRequest rebuildRequest = new RebuildRequest();
rebuildRequest.setEnvironmentCrn(ENVIRONMENT_ID1);
rebuildRequest.setSourceCrn(FREEIPA_CRN);
assertThrows(BadRequestException.class, () -> underTest.rebuild(ACCOUNT_ID, rebuildRequest));
}
Aggregations