DBService implements RolesProvider { boolean updateUserAuthorityFilter(RoleMember roleMember, final String userAuthorityFilter) { int currentState = roleMember.getSystemDisabled() == null ? 0 : roleMember.getSystemDisabled(); int newState = getMemberUserAuthorityState(roleMember.getMemberName(), userAuthorityFilter, currentState); if (newState != currentState) { roleMember.setSystemDisabled(newState); return true; } return false; } DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator); DomainRoleMembers listOverdueReviewRoleMembers(String domainName); @Override List<Role> getRolesByDomain(String domain); ResourceAccessList getResourceAccessList(String principal, String action); AthenzDomain getAthenzDomain(final String domainName, boolean masterCopy); Quota getQuota(String domainName); void executePutRoleSystemMeta(ResourceContext ctx, final String domainName, final String roleName,
           RoleSystemMeta meta, final String attribute, final String auditRef, final String caller); void executePutGroupSystemMeta(ResourceContext ctx, final String domainName, final String groupName,
                                          GroupSystemMeta meta, final String attribute, final String auditRef); void executePutServiceIdentitySystemMeta(ResourceContext ctx, String domainName, String serviceName,
            ServiceIdentitySystemMeta meta, String attribute, String auditRef, String caller); void executePutRoleMeta(ResourceContext ctx, String domainName, String roleName, Role originalRole,
                                   RoleMeta meta, String auditRef, String caller); void executePutGroupMeta(ResourceContext ctx, final String domainName, final String groupName,
                                    GroupMeta meta, final String auditRef); Set<String> getPendingMembershipApproverRoles(int delayDays); Set<String> getPendingGroupMembershipApproverRoles(int delayDays); Map<String, DomainRoleMember> getRoleExpiryMembers(int delayDays); Map<String, DomainRoleMember> getRoleReviewMembers(int delayDays); Map<String, DomainGroupMember> getGroupExpiryMembers(int delayDays); void processExpiredPendingMembers(int pendingRoleMemberLifespan, final String monitorIdentity); void processExpiredPendingGroupMembers(int pendingGroupMemberLifespan, final String monitorIdentity); static int AUDIT_TYPE_ROLE; static int AUDIT_TYPE_POLICY; static int AUDIT_TYPE_SERVICE; static int AUDIT_TYPE_DOMAIN; static int AUDIT_TYPE_ENTITY; static int AUDIT_TYPE_TENANCY; static int AUDIT_TYPE_TEMPLATE; static int AUDIT_TYPE_GROUP; }
@Test public void testUpdateUserAuthorityFilter() { Authority savedAuthority = zms.dbService.zmsConfig.getUserAuthority(); Authority authority = Mockito.mock(Authority.class); Mockito.when(authority.isAttributeSet("user.john", "employee")).thenReturn(true); Mockito.when(authority.isAttributeSet("user.jane", "employee")).thenReturn(false); Mockito.when(authority.isAttributeSet("user.joe", "employee")).thenReturn(true); zms.dbService.zmsConfig.setUserAuthority(authority); RoleMember roleMemberJohn = new RoleMember().setMemberName("user.john").setSystemDisabled(null); assertFalse(zms.dbService.updateUserAuthorityFilter(roleMemberJohn, "employee")); roleMemberJohn.setSystemDisabled(0); assertFalse(zms.dbService.updateUserAuthorityFilter(roleMemberJohn, "employee")); roleMemberJohn.setSystemDisabled(1); assertTrue(zms.dbService.updateUserAuthorityFilter(roleMemberJohn, "employee")); assertEquals(roleMemberJohn.getSystemDisabled(), Integer.valueOf(0)); RoleMember roleMemberJane = new RoleMember().setMemberName("user.jane").setSystemDisabled(null); assertTrue(zms.dbService.updateUserAuthorityFilter(roleMemberJane, "employee")); assertEquals(roleMemberJane.getSystemDisabled(), Integer.valueOf(1)); assertFalse(zms.dbService.updateUserAuthorityFilter(roleMemberJane, "employee")); assertEquals(roleMemberJane.getSystemDisabled(), Integer.valueOf(1)); zms.dbService.zmsConfig.setUserAuthority(savedAuthority); }