@Test void synchronizeAllUsersUnauthorizedAccountId() { SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest(); request.setAccountId(ACCOUNT_ID); String actorInDifferentAccount = "crn:cdp:iam:us-west-1:" + UUID.randomUUID() + ":user:" + UUID.randomUUID(); assertThrows(AccessDeniedException.class, () -> ThreadBasedUserCrnProvider.doAs(actorInDifferentAccount, () -> underTest.synchronizeAllUsers(request))); }
@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);  }