DBService implements RolesProvider { boolean updateGroupMemberDisabledState(ResourceContext ctx, ObjectStoreConnection con, List<GroupMember> groupMembers, final String domainName, final String groupName, final String principal, final String auditRef, final String caller) { boolean bDataChanged = false; for (GroupMember groupMember : groupMembers) { try { if (!con.updateGroupMemberDisabledState(domainName, groupName, groupMember.getMemberName(), principal, groupMember.getSystemDisabled(), auditRef)) { LOG.error("unable to update group member {}", groupMember.getMemberName()); continue; } } catch (Exception ex) { LOG.error("unable to update group member {} error: {}", groupMember.getMemberName(), ex.getMessage()); continue; } StringBuilder auditDetails = new StringBuilder(ZMSConsts.STRING_BLDR_SIZE_DEFAULT); auditLogGroupMember(auditDetails, groupMember, true); auditLogRequest(ctx, domainName, auditRef, caller, ZMSConsts.HTTP_PUT, groupName, auditDetails.toString()); bDataChanged = true; } return bDataChanged; } 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 testUpdateGroupMemberDisabledStateFailure() { final String domainName = "update-group-members-disabled-errs"; final String groupName = "group1"; Mockito.when(mockJdbcConn.updateGroupMemberDisabledState(anyString(), anyString(), anyString(), anyString(), anyInt(), anyString())).thenReturn(false).thenThrow(new ResourceException(400)); ObjectStore saveStore = zms.dbService.store; zms.dbService.store = mockObjStore; List<GroupMember> groupMembers = new ArrayList<>(); groupMembers.add(new GroupMember().setMemberName("user.joe").setSystemDisabled(1)); groupMembers.add(new GroupMember().setMemberName("user.jane").setSystemDisabled(1)); assertFalse(zms.dbService.updateGroupMemberDisabledState(mockDomRsrcCtx, mockJdbcConn, groupMembers, domainName, groupName, adminUser, auditRef, "unit-test")); zms.dbService.store = saveStore; }