use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus in project cloudbreak by hortonworks.
the class FreeIpaServiceTest method getSyncOperationStatusSuccess.
@Test
void getSyncOperationStatusSuccess() {
SyncOperationStatus status = createStatus(SynchronizationStatus.COMPLETED, "nope");
when(userV1Endpoint.getSyncOperationStatusInternal(any(), eq(OPERATION))).thenReturn(status);
SyncOperationStatus result = ThreadBasedUserCrnProvider.doAsInternalActor(() -> underTest.getSyncOperationStatus(ENVCRN, OPERATION));
assertThat(result).isEqualTo(status);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus in project cloudbreak by hortonworks.
the class FreeIpaSynchronizeAllUsersInternalAction method freeIpaAction.
@Override
protected FreeIpaUserSyncTestDto freeIpaAction(TestContext testContext, FreeIpaUserSyncTestDto testDto, FreeIpaClient client) throws Exception {
Log.when(LOGGER, format(" Environment Crn: [%s], freeIpa Crn: %s", testDto.getEnvironmentCrn(), testDto.getRequest().getEnvironments()));
Log.whenJson(LOGGER, format(" FreeIPA sync internal request: %n"), testDto.getRequest());
SyncOperationStatus syncOperationStatus = client.getInternalClient(testContext).getUserV1Endpoint().synchronizeAllUsers(testDto.getRequest());
testDto.setOperationId(syncOperationStatus.getOperationId());
LOGGER.info("Sync is in state: [{}], sync internal operation: [{}] with type: [{}]", syncOperationStatus.getStatus(), syncOperationStatus.getOperationId(), syncOperationStatus.getSyncOperationType());
Log.when(LOGGER, format(" Sync is in state: [%s], sync internal operation: [%s] with type: [%s]", syncOperationStatus.getStatus(), syncOperationStatus.getOperationId(), syncOperationStatus.getSyncOperationType()));
return testDto;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method syncUsers.
private void syncUsers(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn, String accountId) {
try {
SyncOperationStatus lastSyncOperationStatus = ipaClient.getUserV1Endpoint().getLastSyncOperationStatus(environmentCrn);
if (lastSyncOperationStatus.getStatus() == SynchronizationStatus.RUNNING) {
waitToCompleted(testContext, lastSyncOperationStatus.getOperationId(), "Initial or periodic usersync");
}
SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
request.setAccountId(accountId);
request.setEnvironments(Set.of(environmentCrn));
request.setWorkloadCredentialsUpdateType(WorkloadCredentialsUpdateType.FORCE_UPDATE);
try {
SyncOperationStatus syncOperationStatus = ipaClient.getUserV1Endpoint().synchronizeAllUsers(request);
waitToCompleted(testContext, syncOperationStatus.getOperationId(), "Full forced usersync");
} catch (WebApplicationException e) {
if (e.getResponse() != null && Response.Status.CONFLICT.getStatusCode() == e.getResponse().getStatus()) {
logger.info("Usersync is already running");
} else {
throw e;
}
}
} catch (Exception e) {
logger.error("Full forced usersync test failed during upgrade", e);
throw new TestFailException("Full forced usersync test failed during upgrade with: " + e.getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus in project cloudbreak by hortonworks.
the class FreeIpaServiceTest method synchronizeAllUsersInEnvironmentSuccess.
@Test
void synchronizeAllUsersInEnvironmentSuccess() {
SyncOperationStatus status = createStatus(SynchronizationStatus.REQUESTED, "");
when(userV1Endpoint.getLastSyncOperationStatus(any())).thenReturn(createStatus(SynchronizationStatus.COMPLETED, ""));
when(userV1Endpoint.synchronizeAllUsers(any(SynchronizeAllUsersRequest.class))).thenReturn(status);
SyncOperationStatus result = underTest.synchronizeAllUsersInEnvironment(ENVCRN);
assertThat(result).isEqualTo(status);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus in project cloudbreak by hortonworks.
the class SyncOperationToOperationStatusConverterTest method convertFailed.
@Test
void convertFailed() {
OperationState operationState = OperationState.FAILED;
SynchronizationStatus synchronizationStatus = SynchronizationStatus.fromOperationState(operationState);
Operation operation = createSyncOperation(operationState);
String errorMessage = "error message";
operation.setError(errorMessage);
SyncOperationStatus actual = underTest.convert(operation);
assertEqualsDefaults(actual);
assertEquals(synchronizationStatus, actual.getStatus());
assertEquals(List.of(), actual.getSuccess());
assertEquals(List.of(), actual.getFailure());
assertEquals(errorMessage, actual.getError());
}
Aggregations