Search in sources :

Example 61 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testRejectedAlreadyRunning.

@Test
public void testRejectedAlreadyRunning() {
    Operation runningOperation = createCurrentOperation();
    runningOperation.setId(0L);
    runningOperation.setOperationId("other");
    Operation currentOperation = createCurrentOperation();
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(runningOperation, currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertFalse(result.isAccepted());
    assertEquals("There is already a running bind user creation for cluster", result.getRejectionMessage().get());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 62 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testDifferentEnvSameSuffixIsAccepted.

@Test
public void testDifferentEnvSameSuffixIsAccepted() {
    Operation runningOperation = createCurrentOperation();
    runningOperation.setId(0L);
    runningOperation.setOperationId("other");
    runningOperation.setEnvironmentList(List.of("otherEnv"));
    Operation currentOperation = createCurrentOperation();
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(runningOperation, currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertTrue(result.isAccepted());
    assertTrue(result.getRejectionMessage().isEmpty());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 63 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class UpgradeCcmOperationAcceptorTest method createOperation.

private static Operation createOperation(long id, List<String> environmentList) {
    Operation operation = new Operation();
    operation.setId(id);
    operation.setAccountId(ACCOUNT_ID);
    operation.setEnvironmentList(environmentList);
    return operation;
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation)

Example 64 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class UserV1ControllerTest method synchronizeAllUsers.

@Test
void synchronizeAllUsers() {
    Set<String> environments = Set.of(ENV_CRN);
    Set<String> users = Set.of(USER_CRN);
    Set<String> machineUsers = Set.of(MACHINE_USER_CRN);
    SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
    request.setEnvironments(environments);
    request.setUsers(users);
    request.setMachineUsers(machineUsers);
    request.setWorkloadCredentialsUpdateType(WorkloadCredentialsUpdateType.FORCE_UPDATE);
    Operation operation = mock(Operation.class);
    when(userSyncService.synchronizeUsersWithCustomPermissionCheck(any(), any(), any(), any(), any(), any())).thenReturn(operation);
    SyncOperationStatus status = mock(SyncOperationStatus.class);
    when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
    assertEquals(status, ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.synchronizeAllUsers(request)));
    UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(users, machineUsers, Optional.empty());
    verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, environments, userSyncFilter, WorkloadCredentialsUpdateType.FORCE_UPDATE, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
}
Also used : UserSyncRequestFilter(com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter) OperationToSyncOperationStatus(com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) Test(org.junit.jupiter.api.Test)

Example 65 with Operation

use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.

the class UserV1ControllerTest method synchronizeAllUsersAsInternalActor.

@Test
void synchronizeAllUsersAsInternalActor() {
    Set<String> environments = Set.of(ENV_CRN);
    Set<String> users = Set.of(USER_CRN);
    Set<String> machineUsers = Set.of(MACHINE_USER_CRN);
    SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
    request.setEnvironments(environments);
    request.setUsers(users);
    request.setMachineUsers(machineUsers);
    request.setAccountId(ACCOUNT_ID);
    Operation operation = mock(Operation.class);
    when(userSyncService.synchronizeUsersWithCustomPermissionCheck(any(), any(), any(), any(), any(), any())).thenReturn(operation);
    SyncOperationStatus status = mock(SyncOperationStatus.class);
    when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
    assertEquals(status, ThreadBasedUserCrnProvider.doAsInternalActor("crn:altus:iam:us-west-1:altus:user:__internal__actor__", () -> underTest.synchronizeAllUsers(request)));
    UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(users, machineUsers, Optional.empty());
    verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, "crn:altus:iam:us-west-1:altus:user:__internal__actor__", environments, userSyncFilter, WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
}
Also used : UserSyncRequestFilter(com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter) OperationToSyncOperationStatus(com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) Test(org.junit.jupiter.api.Test)

Aggregations

Operation (com.sequenceiq.freeipa.entity.Operation)88 Test (org.junit.jupiter.api.Test)55 Stack (com.sequenceiq.freeipa.entity.Stack)23 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)18 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)15 OperationToSyncOperationStatus (com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus)12 AcceptResult (com.sequenceiq.freeipa.service.freeipa.user.AcceptResult)11 UserSyncRequestFilter (com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)7 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)7 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)6 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)5 FreeIpaUpgradeResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeResponse)4 SynchronizeAllUsersRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest)4 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)3