@Test public void testListWorkloadAdministrationGroupsForMember() { String memberCrn = "fake-crn"; List<String> wags1 = List.of("wag1a", "wag1b"); List<String> wags2 = List.of("wag2a", "wag2b"); PagingProto.PageToken pageToken = PagingProto.PageToken.getDefaultInstance(); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response1 = UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse.newBuilder() .addAllWorkloadAdministrationGroupName(wags1) .setNextPageToken(pageToken) .build(); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response2 = UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse.newBuilder() .addAllWorkloadAdministrationGroupName(wags2) .build(); when(umsClient.listWorkloadAdministrationGroupsForMember(anyString(), eq(memberCrn), eq(Optional.empty()))) .thenReturn(response1); when(umsClient.listWorkloadAdministrationGroupsForMember(anyString(), eq(memberCrn), eq(Optional.of(pageToken)))) .thenReturn(response2); List<String> wags = underTestWithMockUmsClient.listWorkloadAdministrationGroupsForMember("actor-crn", memberCrn, Optional.empty()); verify(umsClient, times(2)).listWorkloadAdministrationGroupsForMember(anyString(), eq(memberCrn), any(Optional.class)); assertTrue(wags.containsAll(wags1)); assertTrue(wags.containsAll(wags2)); }
public List<String> listWorkloadAdministrationGroupsForMember( String actorCrn, String memberCrn, Optional<String> requestId) { requireNonNull(memberCrn); List<String> wags = new ArrayList<>(); try (ManagedChannelWrapper channelWrapper = makeWrapper()) { UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn); LOGGER.debug("Getting workload administration groups for member {}", memberCrn); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response; Optional<PagingProto.PageToken> pageToken = Optional.empty(); do { response = client.listWorkloadAdministrationGroupsForMember( requestId.orElse(UUID.randomUUID().toString()), memberCrn, pageToken); wags.addAll(response.getWorkloadAdministrationGroupNameList()); pageToken = Optional.ofNullable(response.getNextPageToken()); } while (response.hasNextPageToken()); } LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn); return wags; }
GrpcUmsClient { public List<String> listWorkloadAdministrationGroupsForMember( String actorCrn, String memberCrn, Optional<String> requestId) { requireNonNull(memberCrn); List<String> wags = new ArrayList<>(); try (ManagedChannelWrapper channelWrapper = makeWrapper()) { UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn); LOGGER.debug("Getting workload administration groups for member {}", memberCrn); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response; Optional<PagingProto.PageToken> pageToken = Optional.empty(); do { response = client.listWorkloadAdministrationGroupsForMember( requestId.orElse(UUID.randomUUID().toString()), memberCrn, pageToken); wags.addAll(response.getWorkloadAdministrationGroupNameList()); pageToken = Optional.ofNullable(response.getNextPageToken()); } while (response.hasNextPageToken()); } LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn); return wags; } }
GrpcUmsClient { public List<String> listWorkloadAdministrationGroupsForMember( String actorCrn, String memberCrn, Optional<String> requestId) { requireNonNull(memberCrn); List<String> wags = new ArrayList<>(); try (ManagedChannelWrapper channelWrapper = makeWrapper()) { UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn); LOGGER.debug("Getting workload administration groups for member {}", memberCrn); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response; Optional<PagingProto.PageToken> pageToken = Optional.empty(); do { response = client.listWorkloadAdministrationGroupsForMember( requestId.orElse(UUID.randomUUID().toString()), memberCrn, pageToken); wags.addAll(response.getWorkloadAdministrationGroupNameList()); pageToken = Optional.ofNullable(response.getNextPageToken()); } while (response.hasNextPageToken()); } LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn); return wags; }  }
GrpcUmsClient { public List<String> listWorkloadAdministrationGroupsForMember( String actorCrn, String memberCrn, Optional<String> requestId) { requireNonNull(memberCrn); List<String> wags = new ArrayList<>(); try (ManagedChannelWrapper channelWrapper = makeWrapper()) { UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn); LOGGER.debug("Getting workload administration groups for member {}", memberCrn); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response; Optional<PagingProto.PageToken> pageToken = Optional.empty(); do { response = client.listWorkloadAdministrationGroupsForMember( requestId.orElse(UUID.randomUUID().toString()), memberCrn, pageToken); wags.addAll(response.getWorkloadAdministrationGroupNameList()); pageToken = Optional.ofNullable(response.getNextPageToken()); } while (response.hasNextPageToken()); } LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn); return wags; }  static GrpcUmsClient createClient(UmsConfig config, UmsClientConfig clientConfig, Tracer tracer); List<Group> listAllGroups(String actorCrn, String accountId, Optional<String> requestId); List<Group> listGroups(String actorCrn, String accountId, List<String> groupCrns, Optional<String> requestId); List<String> listGroupsForMember(String actorCrn, String accountId, String memberCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsUserCache", key = "{ #actorCrn, #userCrn }") User getUserDetails(String actorCrn, String userCrn, Optional<String> requestId); GetActorWorkloadCredentialsResponse getActorWorkloadCredentials(String actorCrn, String userCrn, Optional<String> requestId); List<User> listAllUsers(String actorCrn, String accountId, Optional<String> requestId); List<User> listUsers(String actorCrn, String accountId, List<String> userCrns, Optional<String> requestId); @Cacheable(cacheNames = "umsMachineUserCache", key = "{ #actorCrn, #userCrn }") MachineUser getMachineUserDetails(String actorCrn, String userCrn, String accountId, Optional<String> requestId); List<MachineUser> listAllMachineUsers(
            String actorCrn, String accountId, boolean includeInternal, Optional<String> requestId); List<MachineUser> listMachineUsers(
            String actorCrn, String accountId, List<String> machineUserCrns, boolean includeInternal, Optional<String> requestId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) Optional<String> createMachineUser(String machineUserName, String userCrn, String accountId, Optional<String> requestId); void deleteMachineUser(String machineUserName, String userCrn, Optional<String> requestId); List<ServicePrincipalCloudIdentities> listServicePrincipalCloudIdentities(
            String actorCrn, String accountId, String environmentCrn, Optional<String> requestId); GetRightsResponse getRightsForUser(String actorCrn, String userCrn, String environmentCrn, Optional<String> requestId); List<String> listWorkloadAdministrationGroupsForMember(
            String actorCrn, String memberCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsAccountCache", key = "{ #actorCrn, #accountId }") Account getAccountDetails(String actorCrn, String accountId, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRoleAssigmentsCache", key = "{ #actorCrn, #userCrn }") List<UserManagementProto.ResourceAssignment> listResourceRoleAssigments(String actorCrn, String userCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRightsCache", key = "{ #userCrn, #right, #resource }") boolean checkRight(String actorCrn, String userCrn, String right, String resource, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRightsCache", key = "{ #actorCrn, #userCrn, #right }") boolean checkRight(String actorCrn, String userCrn, String right, Optional<String> requestId); List<Boolean> hasRights(String actorCrn, String memberCrn, List<AuthorizationProto.RightCheck> rightChecks, Optional<String> requestId); String rightCheckToString(AuthorizationProto.RightCheck rightCheck); Map<String, Boolean> hasRights(String actorCrn, String memberCrn, List<String> resources, String right, Optional<String> requestId); @Cacheable(cacheNames = "umsResourceAssigneesCache", key = "{ #actorCrn, #userCrn, #resourceCrn }") List<UserManagementProto.ResourceAssignee> listAssigneesOfResource(String actorCrn, String userCrn,
            String resourceCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsAuthorizationEntitlementRegisteredCache", key = "{ #actorCrn, #accountId }") boolean isAuthorizationEntitlementRegistered(String actorCrn, String accountId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) void assignMachineUserRole(String userCrn, String accountId, String machineUserCrn, String roleCrn, Optional<String> requestId); void unassignMachineUserRole(String userCrn, String machineUserCrn, String roleCrn, Optional<String> requestId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) AltusCredential generateAccessSecretKeyPair(String actorCrn, String accountId, String machineUserCrn,
            Optional<String> requestId, UserManagementProto.AccessKeyType.Value accessKeyType); AltusCredential createMachineUserAndGenerateKeys(String machineUserName, String userCrn, String accountId, String roleCrn); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) AltusCredential createMachineUserAndGenerateKeys(String machineUserName, String userCrn, String accountId,
            String roleCrn, UserManagementProto.AccessKeyType.Value accessKeyType); void clearMachineUserWithAccessKeysAndRole(String machineUserName, String userCrn, String accountId, String roleCrn); void deleteMachineUserAccessKeys(String actorCrn, String accountId, String machineUserCrn, Optional<String> requestId); boolean doesMachineUserHasAccessKey(String actorCrn, String accountId,
            String machineUserCrn, String accessKeyId); List<AnonymizationRule> getAnonymizationRules(String accountId, String actorCrn); String getIdentityProviderMetadataXml(String accountId, String actorCrn); @Caching(evict = { @CacheEvict(cacheNames = {"umsUserRoleAssigmentsCache"}, key = "#userCrn"), @CacheEvict(cacheNames = {"umsResourceAssigneesCache"}, key = "#userCrn"), @CacheEvict(cacheNames = {"umsUserRightsCache"}, key = "{ #userCrn, #right, #resource }") }) void assignResourceRole(
            String userCrn, String resourceCrn, String resourceRoleCrn, Optional<String> requestId); void assignResourceOwnerRoleIfEntitled(String userCrn, String resourceCrn, String accountId); void unassignResourceRole(String userCrn, String resourceCrn, String resourceRoleCrn, Optional<String> requestId); void notifyResourceDeleted(String resourceCrn, Optional<String> requestId); String setWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); String getWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); void deleteWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); List<UserManagementProto.WorkloadAdministrationGroup> listWorkloadAdministrationGroups(String actorCrn, String accountId,
            Optional<String> requestId); GetEventGenerationIdsResponse getEventGenerationIds(String actorCrn, String accountId, Optional<String> requestId); GetUserSyncStateModelResponse getUserSyncStateModel(
            String actorCrn, String accountId,
            List<UserManagementProto.RightsCheck> rightsChecks, Optional<String> requestId); String getBuiltInDatabusRoleCrn(); String getBuiltInOwnerResourceRoleCrn(); String getBuiltInEnvironmentAdminResourceRoleCrn(); Crn getResourceRoleCrn(String resourceRoleName); Crn getRoleCrn(String roleName); void setTracer(Tracer tracer); }
GrpcUmsClient { public List<String> listWorkloadAdministrationGroupsForMember( String actorCrn, String memberCrn, Optional<String> requestId) { requireNonNull(memberCrn); List<String> wags = new ArrayList<>(); try (ManagedChannelWrapper channelWrapper = makeWrapper()) { UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn); LOGGER.debug("Getting workload administration groups for member {}", memberCrn); UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse response; Optional<PagingProto.PageToken> pageToken = Optional.empty(); do { response = client.listWorkloadAdministrationGroupsForMember( requestId.orElse(UUID.randomUUID().toString()), memberCrn, pageToken); wags.addAll(response.getWorkloadAdministrationGroupNameList()); pageToken = Optional.ofNullable(response.getNextPageToken()); } while (response.hasNextPageToken()); } LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn); return wags; }  static GrpcUmsClient createClient(UmsConfig config, UmsClientConfig clientConfig, Tracer tracer); List<Group> listAllGroups(String actorCrn, String accountId, Optional<String> requestId); List<Group> listGroups(String actorCrn, String accountId, List<String> groupCrns, Optional<String> requestId); List<String> listGroupsForMember(String actorCrn, String accountId, String memberCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsUserCache", key = "{ #actorCrn, #userCrn }") User getUserDetails(String actorCrn, String userCrn, Optional<String> requestId); GetActorWorkloadCredentialsResponse getActorWorkloadCredentials(String actorCrn, String userCrn, Optional<String> requestId); List<User> listAllUsers(String actorCrn, String accountId, Optional<String> requestId); List<User> listUsers(String actorCrn, String accountId, List<String> userCrns, Optional<String> requestId); @Cacheable(cacheNames = "umsMachineUserCache", key = "{ #actorCrn, #userCrn }") MachineUser getMachineUserDetails(String actorCrn, String userCrn, String accountId, Optional<String> requestId); List<MachineUser> listAllMachineUsers(
            String actorCrn, String accountId, boolean includeInternal, Optional<String> requestId); List<MachineUser> listMachineUsers(
            String actorCrn, String accountId, List<String> machineUserCrns, boolean includeInternal, Optional<String> requestId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) Optional<String> createMachineUser(String machineUserName, String userCrn, String accountId, Optional<String> requestId); void deleteMachineUser(String machineUserName, String userCrn, Optional<String> requestId); List<ServicePrincipalCloudIdentities> listServicePrincipalCloudIdentities(
            String actorCrn, String accountId, String environmentCrn, Optional<String> requestId); GetRightsResponse getRightsForUser(String actorCrn, String userCrn, String environmentCrn, Optional<String> requestId); List<String> listWorkloadAdministrationGroupsForMember(
            String actorCrn, String memberCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsAccountCache", key = "{ #actorCrn, #accountId }") Account getAccountDetails(String actorCrn, String accountId, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRoleAssigmentsCache", key = "{ #actorCrn, #userCrn }") List<UserManagementProto.ResourceAssignment> listResourceRoleAssigments(String actorCrn, String userCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRightsCache", key = "{ #userCrn, #right, #resource }") boolean checkRight(String actorCrn, String userCrn, String right, String resource, Optional<String> requestId); @Cacheable(cacheNames = "umsUserRightsCache", key = "{ #actorCrn, #userCrn, #right }") boolean checkRight(String actorCrn, String userCrn, String right, Optional<String> requestId); List<Boolean> hasRights(String actorCrn, String memberCrn, List<AuthorizationProto.RightCheck> rightChecks, Optional<String> requestId); String rightCheckToString(AuthorizationProto.RightCheck rightCheck); Map<String, Boolean> hasRights(String actorCrn, String memberCrn, List<String> resources, String right, Optional<String> requestId); @Cacheable(cacheNames = "umsResourceAssigneesCache", key = "{ #actorCrn, #userCrn, #resourceCrn }") List<UserManagementProto.ResourceAssignee> listAssigneesOfResource(String actorCrn, String userCrn,
            String resourceCrn, Optional<String> requestId); @Cacheable(cacheNames = "umsAuthorizationEntitlementRegisteredCache", key = "{ #actorCrn, #accountId }") boolean isAuthorizationEntitlementRegistered(String actorCrn, String accountId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) void assignMachineUserRole(String userCrn, String accountId, String machineUserCrn, String roleCrn, Optional<String> requestId); void unassignMachineUserRole(String userCrn, String machineUserCrn, String roleCrn, Optional<String> requestId); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) AltusCredential generateAccessSecretKeyPair(String actorCrn, String accountId, String machineUserCrn,
            Optional<String> requestId, UserManagementProto.AccessKeyType.Value accessKeyType); AltusCredential createMachineUserAndGenerateKeys(String machineUserName, String userCrn, String accountId, String roleCrn); @Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000)) AltusCredential createMachineUserAndGenerateKeys(String machineUserName, String userCrn, String accountId,
            String roleCrn, UserManagementProto.AccessKeyType.Value accessKeyType); void clearMachineUserWithAccessKeysAndRole(String machineUserName, String userCrn, String accountId, String roleCrn); void deleteMachineUserAccessKeys(String actorCrn, String accountId, String machineUserCrn, Optional<String> requestId); boolean doesMachineUserHasAccessKey(String actorCrn, String accountId,
            String machineUserCrn, String accessKeyId); List<AnonymizationRule> getAnonymizationRules(String accountId, String actorCrn); String getIdentityProviderMetadataXml(String accountId, String actorCrn); @Caching(evict = { @CacheEvict(cacheNames = {"umsUserRoleAssigmentsCache"}, key = "#userCrn"), @CacheEvict(cacheNames = {"umsResourceAssigneesCache"}, key = "#userCrn"), @CacheEvict(cacheNames = {"umsUserRightsCache"}, key = "{ #userCrn, #right, #resource }") }) void assignResourceRole(
            String userCrn, String resourceCrn, String resourceRoleCrn, Optional<String> requestId); void assignResourceOwnerRoleIfEntitled(String userCrn, String resourceCrn, String accountId); void unassignResourceRole(String userCrn, String resourceCrn, String resourceRoleCrn, Optional<String> requestId); void notifyResourceDeleted(String resourceCrn, Optional<String> requestId); String setWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); String getWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); void deleteWorkloadAdministrationGroupName(String actorCrn, String accountId, Optional<String> requestId, String right, String resource); List<UserManagementProto.WorkloadAdministrationGroup> listWorkloadAdministrationGroups(String actorCrn, String accountId,
            Optional<String> requestId); GetEventGenerationIdsResponse getEventGenerationIds(String actorCrn, String accountId, Optional<String> requestId); GetUserSyncStateModelResponse getUserSyncStateModel(
            String actorCrn, String accountId,
            List<UserManagementProto.RightsCheck> rightsChecks, Optional<String> requestId); String getBuiltInDatabusRoleCrn(); String getBuiltInOwnerResourceRoleCrn(); String getBuiltInEnvironmentAdminResourceRoleCrn(); Crn getResourceRoleCrn(String resourceRoleName); Crn getRoleCrn(String roleName); void setTracer(Tracer tracer);  }