@Test void getEnvToUmsUsersStateMap() { setupMocks(); Map<String, UmsUsersState> umsUsersStateMap = underTest.get( ACCOUNT_ID, ACTOR_CRN, List.of(ENVIRONMENT_CRN), Set.of(), Set.of(), Optional.empty(), true); verifyUmsUsersStateBuilderMap(umsUsersStateMap); }
public Map<String, UmsUsersState> get( String accountId, String actorCrn, Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns, Optional<String> requestIdOptional, boolean fullSync) { List<UserManagementProto.User> users = getUsers(actorCrn, accountId, requestIdOptional, fullSync, userCrns); List<UserManagementProto.MachineUser> machineUsers = getMachineUsers(actorCrn, accountId, requestIdOptional, fullSync, machineUserCrns); Map<String, FmsGroup> crnToFmsGroup = convertGroupsToFmsGroups( grpcUmsClient.listAllGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); Map<UserManagementProto.WorkloadAdministrationGroup, FmsGroup> wags = convertWagsToFmsGroups( grpcUmsClient.listWorkloadAdministrationGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); List<String> requestedWorkloadUsernames = Streams.concat( users.stream().map(UserManagementProto.User::getWorkloadUsername), machineUsers.stream().map(UserManagementProto.MachineUser::getWorkloadUsername)) .collect(Collectors.toList()); Map<String, UmsUsersState> umsUsersStateMap = new HashMap<>(); environmentCrns.forEach(environmentCrn -> { UmsUsersState.Builder umsUsersStateBuilder = new UmsUsersState.Builder() .setWorkloadAdministrationGroups(wags.values()); UsersState.Builder usersStateBuilder = new UsersState.Builder(); addRequestedWorkloadUsernames(umsUsersStateBuilder, requestedWorkloadUsernames); addGroupsToUsersStateBuilder(usersStateBuilder, crnToFmsGroup.values()); Set<String> wagNamesForOtherEnvironments = addWagsToUsersStateBuilder(usersStateBuilder, wags, environmentCrn); ActorHandler actorHandler = ActorHandler.newBuilder() .withFmsGroupConverter(getFmsGroupConverter()) .withUmsUsersStateBuilder(umsUsersStateBuilder) .withUsersStateBuilder(usersStateBuilder) .withCrnToFmsGroup(crnToFmsGroup) .withWagNamesForOtherEnvironments(wagNamesForOtherEnvironments) .build(); EnvironmentAccessChecker environmentAccessChecker = createEnvironmentAccessChecker(environmentCrn); addActorsToUmsUsersStateBuilder(accountId, environmentAccessChecker, users, machineUsers, actorHandler, requestIdOptional); addServicePrincipalsCloudIdentities( umsUsersStateBuilder, grpcUmsClient.listServicePrincipalCloudIdentities( INTERNAL_ACTOR_CRN, accountId, environmentCrn, requestIdOptional)); umsUsersStateBuilder.setUsersState(usersStateBuilder.build()); umsUsersStateMap.put(environmentCrn, umsUsersStateBuilder.build()); }); return umsUsersStateMap; }
DefaultUmsUsersStateProvider extends BaseUmsUsersStateProvider { public Map<String, UmsUsersState> get( String accountId, String actorCrn, Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns, Optional<String> requestIdOptional, boolean fullSync) { List<UserManagementProto.User> users = getUsers(actorCrn, accountId, requestIdOptional, fullSync, userCrns); List<UserManagementProto.MachineUser> machineUsers = getMachineUsers(actorCrn, accountId, requestIdOptional, fullSync, machineUserCrns); Map<String, FmsGroup> crnToFmsGroup = convertGroupsToFmsGroups( grpcUmsClient.listAllGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); Map<UserManagementProto.WorkloadAdministrationGroup, FmsGroup> wags = convertWagsToFmsGroups( grpcUmsClient.listWorkloadAdministrationGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); List<String> requestedWorkloadUsernames = Streams.concat( users.stream().map(UserManagementProto.User::getWorkloadUsername), machineUsers.stream().map(UserManagementProto.MachineUser::getWorkloadUsername)) .collect(Collectors.toList()); Map<String, UmsUsersState> umsUsersStateMap = new HashMap<>(); environmentCrns.forEach(environmentCrn -> { UmsUsersState.Builder umsUsersStateBuilder = new UmsUsersState.Builder() .setWorkloadAdministrationGroups(wags.values()); UsersState.Builder usersStateBuilder = new UsersState.Builder(); addRequestedWorkloadUsernames(umsUsersStateBuilder, requestedWorkloadUsernames); addGroupsToUsersStateBuilder(usersStateBuilder, crnToFmsGroup.values()); Set<String> wagNamesForOtherEnvironments = addWagsToUsersStateBuilder(usersStateBuilder, wags, environmentCrn); ActorHandler actorHandler = ActorHandler.newBuilder() .withFmsGroupConverter(getFmsGroupConverter()) .withUmsUsersStateBuilder(umsUsersStateBuilder) .withUsersStateBuilder(usersStateBuilder) .withCrnToFmsGroup(crnToFmsGroup) .withWagNamesForOtherEnvironments(wagNamesForOtherEnvironments) .build(); EnvironmentAccessChecker environmentAccessChecker = createEnvironmentAccessChecker(environmentCrn); addActorsToUmsUsersStateBuilder(accountId, environmentAccessChecker, users, machineUsers, actorHandler, requestIdOptional); addServicePrincipalsCloudIdentities( umsUsersStateBuilder, grpcUmsClient.listServicePrincipalCloudIdentities( INTERNAL_ACTOR_CRN, accountId, environmentCrn, requestIdOptional)); umsUsersStateBuilder.setUsersState(usersStateBuilder.build()); umsUsersStateMap.put(environmentCrn, umsUsersStateBuilder.build()); }); return umsUsersStateMap; } }
DefaultUmsUsersStateProvider extends BaseUmsUsersStateProvider { public Map<String, UmsUsersState> get( String accountId, String actorCrn, Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns, Optional<String> requestIdOptional, boolean fullSync) { List<UserManagementProto.User> users = getUsers(actorCrn, accountId, requestIdOptional, fullSync, userCrns); List<UserManagementProto.MachineUser> machineUsers = getMachineUsers(actorCrn, accountId, requestIdOptional, fullSync, machineUserCrns); Map<String, FmsGroup> crnToFmsGroup = convertGroupsToFmsGroups( grpcUmsClient.listAllGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); Map<UserManagementProto.WorkloadAdministrationGroup, FmsGroup> wags = convertWagsToFmsGroups( grpcUmsClient.listWorkloadAdministrationGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); List<String> requestedWorkloadUsernames = Streams.concat( users.stream().map(UserManagementProto.User::getWorkloadUsername), machineUsers.stream().map(UserManagementProto.MachineUser::getWorkloadUsername)) .collect(Collectors.toList()); Map<String, UmsUsersState> umsUsersStateMap = new HashMap<>(); environmentCrns.forEach(environmentCrn -> { UmsUsersState.Builder umsUsersStateBuilder = new UmsUsersState.Builder() .setWorkloadAdministrationGroups(wags.values()); UsersState.Builder usersStateBuilder = new UsersState.Builder(); addRequestedWorkloadUsernames(umsUsersStateBuilder, requestedWorkloadUsernames); addGroupsToUsersStateBuilder(usersStateBuilder, crnToFmsGroup.values()); Set<String> wagNamesForOtherEnvironments = addWagsToUsersStateBuilder(usersStateBuilder, wags, environmentCrn); ActorHandler actorHandler = ActorHandler.newBuilder() .withFmsGroupConverter(getFmsGroupConverter()) .withUmsUsersStateBuilder(umsUsersStateBuilder) .withUsersStateBuilder(usersStateBuilder) .withCrnToFmsGroup(crnToFmsGroup) .withWagNamesForOtherEnvironments(wagNamesForOtherEnvironments) .build(); EnvironmentAccessChecker environmentAccessChecker = createEnvironmentAccessChecker(environmentCrn); addActorsToUmsUsersStateBuilder(accountId, environmentAccessChecker, users, machineUsers, actorHandler, requestIdOptional); addServicePrincipalsCloudIdentities( umsUsersStateBuilder, grpcUmsClient.listServicePrincipalCloudIdentities( INTERNAL_ACTOR_CRN, accountId, environmentCrn, requestIdOptional)); umsUsersStateBuilder.setUsersState(usersStateBuilder.build()); umsUsersStateMap.put(environmentCrn, umsUsersStateBuilder.build()); }); return umsUsersStateMap; }  }
DefaultUmsUsersStateProvider extends BaseUmsUsersStateProvider { public Map<String, UmsUsersState> get( String accountId, String actorCrn, Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns, Optional<String> requestIdOptional, boolean fullSync) { List<UserManagementProto.User> users = getUsers(actorCrn, accountId, requestIdOptional, fullSync, userCrns); List<UserManagementProto.MachineUser> machineUsers = getMachineUsers(actorCrn, accountId, requestIdOptional, fullSync, machineUserCrns); Map<String, FmsGroup> crnToFmsGroup = convertGroupsToFmsGroups( grpcUmsClient.listAllGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); Map<UserManagementProto.WorkloadAdministrationGroup, FmsGroup> wags = convertWagsToFmsGroups( grpcUmsClient.listWorkloadAdministrationGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); List<String> requestedWorkloadUsernames = Streams.concat( users.stream().map(UserManagementProto.User::getWorkloadUsername), machineUsers.stream().map(UserManagementProto.MachineUser::getWorkloadUsername)) .collect(Collectors.toList()); Map<String, UmsUsersState> umsUsersStateMap = new HashMap<>(); environmentCrns.forEach(environmentCrn -> { UmsUsersState.Builder umsUsersStateBuilder = new UmsUsersState.Builder() .setWorkloadAdministrationGroups(wags.values()); UsersState.Builder usersStateBuilder = new UsersState.Builder(); addRequestedWorkloadUsernames(umsUsersStateBuilder, requestedWorkloadUsernames); addGroupsToUsersStateBuilder(usersStateBuilder, crnToFmsGroup.values()); Set<String> wagNamesForOtherEnvironments = addWagsToUsersStateBuilder(usersStateBuilder, wags, environmentCrn); ActorHandler actorHandler = ActorHandler.newBuilder() .withFmsGroupConverter(getFmsGroupConverter()) .withUmsUsersStateBuilder(umsUsersStateBuilder) .withUsersStateBuilder(usersStateBuilder) .withCrnToFmsGroup(crnToFmsGroup) .withWagNamesForOtherEnvironments(wagNamesForOtherEnvironments) .build(); EnvironmentAccessChecker environmentAccessChecker = createEnvironmentAccessChecker(environmentCrn); addActorsToUmsUsersStateBuilder(accountId, environmentAccessChecker, users, machineUsers, actorHandler, requestIdOptional); addServicePrincipalsCloudIdentities( umsUsersStateBuilder, grpcUmsClient.listServicePrincipalCloudIdentities( INTERNAL_ACTOR_CRN, accountId, environmentCrn, requestIdOptional)); umsUsersStateBuilder.setUsersState(usersStateBuilder.build()); umsUsersStateMap.put(environmentCrn, umsUsersStateBuilder.build()); }); return umsUsersStateMap; }  Map<String, UmsUsersState> get(
            String accountId, String actorCrn,
            Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns,
            Optional<String> requestIdOptional, boolean fullSync); }
DefaultUmsUsersStateProvider extends BaseUmsUsersStateProvider { public Map<String, UmsUsersState> get( String accountId, String actorCrn, Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns, Optional<String> requestIdOptional, boolean fullSync) { List<UserManagementProto.User> users = getUsers(actorCrn, accountId, requestIdOptional, fullSync, userCrns); List<UserManagementProto.MachineUser> machineUsers = getMachineUsers(actorCrn, accountId, requestIdOptional, fullSync, machineUserCrns); Map<String, FmsGroup> crnToFmsGroup = convertGroupsToFmsGroups( grpcUmsClient.listAllGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); Map<UserManagementProto.WorkloadAdministrationGroup, FmsGroup> wags = convertWagsToFmsGroups( grpcUmsClient.listWorkloadAdministrationGroups(INTERNAL_ACTOR_CRN, accountId, requestIdOptional)); List<String> requestedWorkloadUsernames = Streams.concat( users.stream().map(UserManagementProto.User::getWorkloadUsername), machineUsers.stream().map(UserManagementProto.MachineUser::getWorkloadUsername)) .collect(Collectors.toList()); Map<String, UmsUsersState> umsUsersStateMap = new HashMap<>(); environmentCrns.forEach(environmentCrn -> { UmsUsersState.Builder umsUsersStateBuilder = new UmsUsersState.Builder() .setWorkloadAdministrationGroups(wags.values()); UsersState.Builder usersStateBuilder = new UsersState.Builder(); addRequestedWorkloadUsernames(umsUsersStateBuilder, requestedWorkloadUsernames); addGroupsToUsersStateBuilder(usersStateBuilder, crnToFmsGroup.values()); Set<String> wagNamesForOtherEnvironments = addWagsToUsersStateBuilder(usersStateBuilder, wags, environmentCrn); ActorHandler actorHandler = ActorHandler.newBuilder() .withFmsGroupConverter(getFmsGroupConverter()) .withUmsUsersStateBuilder(umsUsersStateBuilder) .withUsersStateBuilder(usersStateBuilder) .withCrnToFmsGroup(crnToFmsGroup) .withWagNamesForOtherEnvironments(wagNamesForOtherEnvironments) .build(); EnvironmentAccessChecker environmentAccessChecker = createEnvironmentAccessChecker(environmentCrn); addActorsToUmsUsersStateBuilder(accountId, environmentAccessChecker, users, machineUsers, actorHandler, requestIdOptional); addServicePrincipalsCloudIdentities( umsUsersStateBuilder, grpcUmsClient.listServicePrincipalCloudIdentities( INTERNAL_ACTOR_CRN, accountId, environmentCrn, requestIdOptional)); umsUsersStateBuilder.setUsersState(usersStateBuilder.build()); umsUsersStateMap.put(environmentCrn, umsUsersStateBuilder.build()); }); return umsUsersStateMap; }  Map<String, UmsUsersState> get(
            String accountId, String actorCrn,
            Collection<String> environmentCrns, Set<String> userCrns, Set<String> machineUserCrns,
            Optional<String> requestIdOptional, boolean fullSync);  }