@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())).thenReturn(operation); SyncOperationStatus status = mock(SyncOperationStatus.class); when(operationToSyncOperationStatus.convert(operation)).thenReturn(status); assertEquals(status, ThreadBasedUserCrnProvider.doAsInternalActor(() -> underTest.synchronizeAllUsers(request))); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(users, machineUsers, Optional.empty()); verify(userSyncService, times(1)).synchronizeUsersWithCustomPermissionCheck(ACCOUNT_ID, INTERNAL_ACTOR_CRN, environments, userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); }
@Override @CustomPermissionCheck public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) { String userCrn = checkActorCrn(); String accountId = determineAccountId(userCrn, request.getAccountId()); LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers())); Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation)); }
UserV1Controller implements UserV1Endpoint { @Override @CustomPermissionCheck public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) { String userCrn = checkActorCrn(); String accountId = determineAccountId(userCrn, request.getAccountId()); LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers())); Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation)); } }
UserV1Controller implements UserV1Endpoint { @Override @CustomPermissionCheck public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) { String userCrn = checkActorCrn(); String accountId = determineAccountId(userCrn, request.getAccountId()); LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers())); Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation)); }  }
UserV1Controller implements UserV1Endpoint { @Override @CustomPermissionCheck public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) { String userCrn = checkActorCrn(); String accountId = determineAccountId(userCrn, request.getAccountId()); LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers())); Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation)); }  @Override @CustomPermissionCheck SyncOperationStatus synchronizeUser(SynchronizeUserRequest request); @Override @CustomPermissionCheck SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request); @Override @CustomPermissionCheck @CheckPermissionByAccount(action = AuthorizationResourceAction.ENVIRONMENT_READ) SyncOperationStatus setPassword(SetPasswordRequest request); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) SyncOperationStatus getSyncOperationStatus(@NotNull String operationId); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) EnvironmentUserSyncState getUserSyncState(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn); }
UserV1Controller implements UserV1Endpoint { @Override @CustomPermissionCheck public SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request) { String userCrn = checkActorCrn(); String accountId = determineAccountId(userCrn, request.getAccountId()); LOGGER.debug("synchronizeAllUsers() requested for account {}", accountId); UserSyncRequestFilter userSyncFilter = new UserSyncRequestFilter(nullToEmpty(request.getUsers()), nullToEmpty(request.getMachineUsers()), getOptionalDeletedWorkloadUser(request.getDeletedWorkloadUsers())); Operation syncOperation = userSyncService.synchronizeUsersWithCustomPermissionCheck(accountId, userCrn, nullToEmpty(request.getEnvironments()), userSyncFilter, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(syncOperation)); }  @Override @CustomPermissionCheck SyncOperationStatus synchronizeUser(SynchronizeUserRequest request); @Override @CustomPermissionCheck SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request); @Override @CustomPermissionCheck @CheckPermissionByAccount(action = AuthorizationResourceAction.ENVIRONMENT_READ) SyncOperationStatus setPassword(SetPasswordRequest request); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) SyncOperationStatus getSyncOperationStatus(@NotNull String operationId); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) EnvironmentUserSyncState getUserSyncState(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn);  }