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)));
}
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);
}
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);
}
Aggregations