Search in sources :

Example 1 with SyncOperationStatus

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);
}
Also used : SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Test(org.junit.jupiter.api.Test)

Example 2 with SyncOperationStatus

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;
}
Also used : SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)

Example 3 with SyncOperationStatus

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);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 4 with SyncOperationStatus

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);
}
Also used : SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) Test(org.junit.jupiter.api.Test)

Example 5 with SyncOperationStatus

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());
}
Also used : SynchronizationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) OperationState(com.sequenceiq.freeipa.api.v1.operation.model.OperationState) Test(org.junit.jupiter.api.Test)

Aggregations

SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)26 Test (org.junit.jupiter.api.Test)18 Operation (com.sequenceiq.freeipa.entity.Operation)15 OperationToSyncOperationStatus (com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus)12 SynchronizeAllUsersRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest)8 UserSyncRequestFilter (com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)3 SetPasswordRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SetPasswordRequest)3 SynchronizationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus)3 SynchronizeUserRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest)3 OperationState (com.sequenceiq.freeipa.api.v1.operation.model.OperationState)3 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 UserV1Endpoint (com.sequenceiq.freeipa.api.v1.freeipa.user.UserV1Endpoint)1 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1