DBService implements RolesProvider { void updateRoleMetaFields(Role role, RoleMeta meta) { if (meta.getSelfServe() != null) { role.setSelfServe(meta.getSelfServe()); } if (meta.getMemberExpiryDays() != null) { role.setMemberExpiryDays(meta.getMemberExpiryDays()); } if (meta.getServiceExpiryDays() != null) { role.setServiceExpiryDays(meta.getServiceExpiryDays()); } if (meta.getGroupExpiryDays() != null) { role.setGroupExpiryDays(meta.getGroupExpiryDays()); } if (meta.getTokenExpiryMins() != null) { role.setTokenExpiryMins(meta.getTokenExpiryMins()); } if (meta.getCertExpiryMins() != null) { role.setCertExpiryMins(meta.getCertExpiryMins()); } if (meta.getSignAlgorithm() != null) { role.setSignAlgorithm(meta.getSignAlgorithm()); } if (meta.getReviewEnabled() != null) { role.setReviewEnabled(meta.getReviewEnabled()); } if (meta.getNotifyRoles() != null) { role.setNotifyRoles(meta.getNotifyRoles()); } if (meta.getMemberReviewDays() != null) { role.setMemberReviewDays(meta.getMemberReviewDays()); } if (meta.getServiceReviewDays() != null) { role.setServiceReviewDays(meta.getServiceReviewDays()); } if (meta.getUserAuthorityFilter() != null) { role.setUserAuthorityFilter(meta.getUserAuthorityFilter()); } if (meta.getUserAuthorityExpiration() != null) { role.setUserAuthorityExpiration(meta.getUserAuthorityExpiration()); } } 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 testUpdateRoleMetaFields() { Role role = new Role(); RoleMeta meta = new RoleMeta().setSelfServe(true) .setReviewEnabled(true).setNotifyRoles("role1"); zms.dbService.updateRoleMetaFields(role, meta); assertTrue(role.getSelfServe()); assertTrue(role.getReviewEnabled()); assertEquals(role.getNotifyRoles(), "role1"); meta = new RoleMeta().setReviewEnabled(false); zms.dbService.updateRoleMetaFields(role, meta); assertTrue(role.getSelfServe()); assertFalse(role.getReviewEnabled()); assertEquals(role.getNotifyRoles(), "role1"); meta = new RoleMeta().setNotifyRoles("role2"); zms.dbService.updateRoleMetaFields(role, meta); assertTrue(role.getSelfServe()); assertFalse(role.getReviewEnabled()); assertEquals(role.getNotifyRoles(), "role2"); meta = new RoleMeta().setUserAuthorityExpiration("expiry"); zms.dbService.updateRoleMetaFields(role, meta); assertEquals(role.getNotifyRoles(), "role2"); assertEquals(role.getUserAuthorityExpiration(), "expiry"); meta = new RoleMeta().setUserAuthorityFilter("attr1"); zms.dbService.updateRoleMetaFields(role, meta); assertEquals(role.getNotifyRoles(), "role2"); assertEquals(role.getUserAuthorityExpiration(), "expiry"); assertEquals(role.getUserAuthorityFilter(), "attr1"); }