use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserV1ControllerTest method setPasswordRejected.
@Test
void setPasswordRejected() {
String password = "password";
SetPasswordRequest request = mock(SetPasswordRequest.class);
when(request.getPassword()).thenReturn(password);
Operation operation = mock(Operation.class);
when(passwordService.setPasswordWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, password, new HashSet<>(), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)).thenReturn(operation);
SyncOperationStatus status = mock(SyncOperationStatus.class);
when(status.getStatus()).thenReturn(SynchronizationStatus.REJECTED);
when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
assertThrows(SyncOperationAlreadyRunningException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.setPassword(request)));
}
use of com.sequenceiq.freeipa.entity.Operation 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.entity.Operation in project cloudbreak by hortonworks.
the class UserV1ControllerTest method getStatus.
@Test
void getStatus() {
String operationId = "testId";
Operation operation = mock(Operation.class);
when(operationService.getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId)).thenReturn(operation);
SyncOperationStatus status = mock(SyncOperationStatus.class);
when(operationToSyncOperationStatus.convert(operation)).thenReturn(status);
assertEquals(status, ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getSyncOperationStatus(operationId)));
verify(operationService, times(1)).getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserV1ControllerTest method synchronizeAllUsersDeleteWorkloadUser.
@Test
void synchronizeAllUsersDeleteWorkloadUser() {
Set<String> users = Set.of(USER_CRN);
String deletedWorkloadUser = "workload-user";
SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
request.setEnvironments(Set.of());
request.setUsers(users);
request.setDeletedWorkloadUsers(Set.of(deletedWorkloadUser));
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, Set.of(), Optional.of(deletedWorkloadUser));
verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, Set.of(), userSyncFilter, WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserV1ControllerTest method synchronizeAllUsersRejected.
@Test
void synchronizeAllUsersRejected() {
Set<String> environments = Set.of(ENV_CRN);
Set<String> users = Set.of(USER_CRN);
SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
request.setEnvironments(environments);
request.setUsers(users);
Operation operation = mock(Operation.class);
UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(users, Set.of(), Optional.empty());
when(userSyncService.synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, environments, 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);
assertThrows(SyncOperationAlreadyRunningException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.synchronizeAllUsers(request)));
}
Aggregations