use of org.pmiops.workbench.model.SynchronizeUserAccessRequest in project workbench by all-of-us.
the class CloudTaskUserControllerTest method testSynchronizeAccess.
@Test
public void testSynchronizeAccess() {
when(mockAccessModuleService.getAccessModuleStatus(userA, DbAccessModuleName.TWO_FACTOR_AUTH)).thenReturn(Optional.of(new AccessModuleStatus().completionEpochMillis(123L)));
when(mockAccessModuleService.getAccessModuleStatus(userB, DbAccessModuleName.TWO_FACTOR_AUTH)).thenReturn(Optional.of(new AccessModuleStatus()));
// kluge to prevent test NPEs on the return value of syncDuccVersionStatus()
when(mockUserService.syncDuccVersionStatus(userA, Agent.asSystem())).thenReturn(userA);
when(mockUserService.syncDuccVersionStatus(userB, Agent.asSystem())).thenReturn(userB);
controller.synchronizeUserAccess(new SynchronizeUserAccessRequest().addUserIdsItem(userA.getUserId()).addUserIdsItem(userB.getUserId()));
// Ideally we would use a real implementation of UserService and mock its external deps, but
// unfortunately UserService is too sprawling to replicate in a unit test.
// we sync DUCC for all users
verify(mockUserService).syncDuccVersionStatus(userA, Agent.asSystem());
verify(mockUserService).syncDuccVersionStatus(userB, Agent.asSystem());
// we only sync 2FA users with completed 2FA
verify(mockUserService).syncTwoFactorAuthStatus(userA, Agent.asSystem());
// normally we would expect the userService sync methods to add to this count, but userService
// is mocked so we only see the direct calls from synchronizeUserAccess(), one per user
verify(mockUserService, times(2)).updateUserAccessTiers(any(), any());
verifyNoMoreInteractions(mockUserService);
}
use of org.pmiops.workbench.model.SynchronizeUserAccessRequest in project workbench by all-of-us.
the class OfflineUserControllerTest method testSynchronizeUserAccess.
@Test
public void testSynchronizeUserAccess() {
offlineUserController.synchronizeUserAccess();
// We set a batch size of 3, so we expect two cloud tasks.
List<SynchronizeUserAccessRequest> expectedRequests = ImmutableList.of(new SynchronizeUserAccessRequest().userIds(ImmutableList.of(1L, 2L, 3L)), new SynchronizeUserAccessRequest().userIds(ImmutableList.of(4L)));
for (SynchronizeUserAccessRequest expected : expectedRequests) {
verify(mockCloudTasksClient).createTask(matches(Pattern.compile(".*/synchronizeAccessQueue$")), argThat(taskRequest -> expected.equals(cloudTaskToSynchronizeRequest(taskRequest))));
}
verifyNoMoreInteractions(mockCloudTasksClient);
}
Aggregations