DataStore implements DataCacheProvider, RolesProvider { public void getAccessibleRoles(DataCache data, String domainName, String identity, String[] requestedRoleList, Set<String> accessibleRoles, boolean keepFullName) { if (data == null) { return; } final String rolePrefix = domainName + ROLE_POSTFIX; processStandardMembership(data.getMemberRoleSet(identity), rolePrefix, requestedRoleList, accessibleRoles, keepFullName); processStandardMembership(data.getAllMemberRoleSet(), rolePrefix, requestedRoleList, accessibleRoles, keepFullName); Map<String, Set<MemberRole>> roleSetMap = data.getPrefixMemberRoleSetMap(); for (String identityPrefix : roleSetMap.keySet()) { if (identity.startsWith(identityPrefix)) { processStandardMembership(roleSetMap.get(identityPrefix), rolePrefix, requestedRoleList, accessibleRoles, keepFullName); } } processGroupMembership(data, identity, rolePrefix, requestedRoleList, accessibleRoles, keepFullName); processTrustMembership(data, identity, rolePrefix, requestedRoleList, accessibleRoles, keepFullName); } DataStore(ChangeLogStore clogStore, CloudStore cloudStore); JWKList getZtsJWKList(Boolean rfc); void init(); boolean processDomain(SignedDomain signedDomain, boolean saveInStore); boolean processDomainDeletes(); void processDomainChecks(); boolean processDomainUpdates(); DomainData getDomainData(String name); void addDomainToCache(String name, DataCache dataCache); @Override DataCache getDataCache(String domainName); List<GroupMember> getGroupMembers(final String groupName); void getAccessibleRoles(DataCache data, String domainName, String identity,
            String[] requestedRoleList, Set<String> accessibleRoles, boolean keepFullName); String getPublicKey(String domain, String service, String keyId); HostServices getHostServices(String host); CloudStore getCloudStore(); void setCloudStore(CloudStore cloudStore); Cache<String, DataCache> getCacheStore(); Map<String, String> getPublicKeyCache(); @Override List<Role> getRolesByDomain(String domain);  }
@Test public void testGetAccessibleRoles() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.loadAthenzPublicKeys(); SignedDomain signedDomain = createSignedDomain("coretech", "weather"); store.processDomain(signedDomain, true); Set<String> accessibleRoles = new HashSet<>(); DataCache data = store.getDataCache("coretech"); store.getAccessibleRoles(data, "coretech", "user_domain.user1", null, accessibleRoles, false); assertEquals(accessibleRoles.size(), 1); assertTrue(accessibleRoles.contains("writers")); }