AuthzHelper { public static void removeRoleMembers(List<RoleMember> originalRoleMembers, List<RoleMember> removeRoleMembers) { if (removeRoleMembers == null || originalRoleMembers == null) { return; } for (RoleMember removeMember : removeRoleMembers) { originalRoleMembers.removeIf(item -> item.getMemberName().equalsIgnoreCase(removeMember.getMemberName())); } }  static void removeRoleMembers(List<RoleMember> originalRoleMembers, List<RoleMember> removeRoleMembers); static void removeGroupMembers(List<GroupMember> originalGroupMembers, List<GroupMember> removeGroupMembers); static boolean isMemberDisabled(Integer systemDisabled); static boolean isMemberExpired(Timestamp expiration, long currentTime); static boolean shouldSkipGroupMember(GroupMember member, long currentTime); static boolean isMemberOfGroup(List<GroupMember> groupMembers, final String member); static boolean checkGroupMemberValidity(List<GroupMember> groupMembers, final String member); static boolean memberNameMatch(final String memberName, final  String matchName); static boolean shouldRunDelegatedTrustCheck(final String trust, final String trustDomain); static String retrieveResourceDomain(String resource, String op, String trustDomain); static String extractResourceDomainName(final String resource); static boolean authorityAuthorizationAllowed(Principal principal); static boolean checkRoleMemberValidity(List<RoleMember> roleMembers, final String member,
                                                  GroupMembersFetcher groupMembersFetcher); static boolean isMemberOfRole(Role role, final String member, GroupMembersFetcher groupMembersFetcher); static boolean assumeRoleResourceMatch(String roleName, Assertion assertion); static boolean matchDelegatedTrustPolicy(Policy policy, final String roleName, final String roleMember,
                                                    List<Role> roles, GroupMembersFetcher groupMembersFetcher); static boolean matchDelegatedTrustAssertion(Assertion assertion, final String roleName, final String roleMember,
                                                       List<Role> roles, GroupMembersFetcher groupMembersFetcher);  }
@Test(dataProvider = "members") public void testRemoveRoleMembers(List<String> originalRoleMembersList, List<String> removeRoleMembersList, int expectedSize) { List<RoleMember> originalRoleMembers = convertMembersToRoleMembers(originalRoleMembersList); List<RoleMember> removeRoleMembers = convertMembersToRoleMembers(removeRoleMembersList); AuthzHelper.removeRoleMembers(originalRoleMembers, removeRoleMembers); for (RoleMember orgMember : originalRoleMembers) { for (RoleMember removeMember : removeRoleMembers) { if (orgMember.getMemberName().equalsIgnoreCase(removeMember.getMemberName())) { fail("Should have removed " + removeMember.getMemberName()); } } } assertEquals(originalRoleMembers.size(), expectedSize); }
@Test public void testRemoveRoleMembersInvalidInput() { List<RoleMember> list = Collections.singletonList(new RoleMember().setMemberName("member1")); AuthzHelper.removeRoleMembers(list, null); assertEquals(list.size(), 1); assertEquals(list.get(0).getMemberName(), "member1"); AuthzHelper.removeRoleMembers(null, list); assertEquals(list.size(), 1); assertEquals(list.get(0).getMemberName(), "member1"); }