Search in sources :

Example 1 with SynchronizeUserRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest in project cloudbreak by hortonworks.

the class UserV1ControllerTest method synchronizeUserRejected.

@Test
void synchronizeUserRejected() {
    Operation operation = mock(Operation.class);
    UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(Set.of(USER_CRN), Set.of(), Optional.empty());
    when(userSyncService.synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, Set.of(), userSyncFilter, WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)).thenReturn(operation);
    SyncOperationStatus status = mock(SyncOperationStatus.class);
    when(status.getStatus()).thenReturn(SynchronizationStatus.REJECTED);
    when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
    SynchronizeUserRequest request = mock(SynchronizeUserRequest.class);
    assertThrows(SyncOperationAlreadyRunningException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.synchronizeUser(request)));
}
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) SynchronizeUserRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 2 with SynchronizeUserRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest in project cloudbreak by hortonworks.

the class UserV1ControllerTest method synchronizeUserMachineUser.

@Test
void synchronizeUserMachineUser() {
    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);
    SynchronizeUserRequest request = mock(SynchronizeUserRequest.class);
    assertEquals(status, ThreadBasedUserCrnProvider.doAs(MACHINE_USER_CRN, () -> underTest.synchronizeUser(request)));
    UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(Set.of(), Set.of(MACHINE_USER_CRN), Optional.empty());
    verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, MACHINE_USER_CRN, Set.of(), 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) SynchronizeUserRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 3 with SynchronizeUserRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest in project cloudbreak by hortonworks.

the class UserV1ControllerTest method synchronizeUser.

@Test
void synchronizeUser() {
    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);
    SynchronizeUserRequest request = mock(SynchronizeUserRequest.class);
    assertEquals(status, ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.synchronizeUser(request)));
    UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(Set.of(USER_CRN), Set.of(), Optional.empty());
    verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, Set.of(), 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) SynchronizeUserRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Aggregations

SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)3 SynchronizeUserRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeUserRequest)3 OperationToSyncOperationStatus (com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus)3 Operation (com.sequenceiq.freeipa.entity.Operation)3 UserSyncRequestFilter (com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter)3 Test (org.junit.jupiter.api.Test)3