DBService implements RolesProvider { boolean auditLogRoleMember(StringBuilder auditDetails, RoleMember roleMember, boolean firstEntry) { firstEntry = auditLogSeparator(auditDetails, firstEntry); auditDetails.append("{\"member\": \"").append(roleMember.getMemberName()).append('"'); if (roleMember.getExpiration() != null) { auditDetails.append(", \"expiration\": \"").append(roleMember.getExpiration().toString()).append('"'); } auditDetails.append(", \"approved\": "); auditDetails.append(roleMember.getApproved() == Boolean.FALSE ? "false" : "true"); auditDetails.append(", \"system-disabled\": "); auditDetails.append(roleMember.getSystemDisabled() == null ? 0 : roleMember.getSystemDisabled()); auditDetails.append("}"); return firstEntry; } 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 testAuditLogRoleMember() { StringBuilder auditDetails = new StringBuilder(ZMSConsts.STRING_BLDR_SIZE_DEFAULT); RoleMember rm = new RoleMember().setMemberName("user.joe"); zms.dbService.auditLogRoleMember(auditDetails, rm, true); assertEquals(auditDetails.toString(), "{\"member\": \"user.joe\", \"approved\": true, \"system-disabled\": 0}"); auditDetails.setLength(0); RoleMember rm2 = new RoleMember().setMemberName("user.joe").setApproved(true).setSystemDisabled(0); zms.dbService.auditLogRoleMember(auditDetails, rm2, true); assertEquals(auditDetails.toString(), "{\"member\": \"user.joe\", \"approved\": true, \"system-disabled\": 0}"); auditDetails.setLength(0); RoleMember rm3 = new RoleMember().setMemberName("user.joe").setApproved(false).setSystemDisabled(1); zms.dbService.auditLogRoleMember(auditDetails, rm3, true); assertEquals(auditDetails.toString(), "{\"member\": \"user.joe\", \"approved\": false, \"system-disabled\": 1}"); auditDetails.setLength(0); RoleMember rm4 = new RoleMember().setMemberName("user.joe") .setApproved(false).setExpiration(Timestamp.fromMillis(1000)).setSystemDisabled(3); zms.dbService.auditLogRoleMember(auditDetails, rm4, true); assertEquals(auditDetails.toString(), "{\"member\": \"user.joe\", \"expiration\": \"1970-01-01T00:00:01.000Z\", \"approved\": false, \"system-disabled\": 3}"); }