DataStore implements DataCacheProvider, RolesProvider { void processSingleTrustedDomainRole(String roleName, String rolePrefix, String[] requestedRoleList, Set<MemberRole> memberRoles, Set<String> accessibleRoles, boolean keepFullName) { if (!roleMatchInSet(roleName, memberRoles)) { return; } addRoleToList(roleName, 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 testProcessSingleTrustedDomainRoleNoMatchInSet() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); Set<String> accessibleRoles = new HashSet<>(); String prefix = "coretech" + ROLE_POSTFIX; String role = "coretech:role.writers"; Set<MemberRole> memberRoles = new HashSet<>(); memberRoles.add(new MemberRole("coretech:role.admin", 0)); memberRoles.add(new MemberRole("coretech:role.readers", 0)); store.processSingleTrustedDomainRole(role, prefix, null, memberRoles, accessibleRoles, false); assertEquals(accessibleRoles.size(), 0); }
@Test public void testProcessSingleTrustedDomainRoleAddRoleTrue() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); Set<String> accessibleRoles = new HashSet<>(); String prefix = "coretech" + ROLE_POSTFIX; String role = "coretech:role.readers"; Set<MemberRole> memberRoles = new HashSet<>(); memberRoles.add(new MemberRole("coretech:role.admin", 0)); memberRoles.add(new MemberRole("coretech:role.readers", 0)); store.processSingleTrustedDomainRole(role, prefix, null, memberRoles, accessibleRoles, false); assertTrue(accessibleRoles.contains("readers")); }
@Test public void testProcessSingleTrustedDomainRoleAddRoleFalse() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); Set<String> accessibleRoles = new HashSet<>(); String prefix = "coretech2" + ROLE_POSTFIX; String role = "coretech:role.readers"; Set<MemberRole> memberRoles = new HashSet<>(); memberRoles.add(new MemberRole("coretech:role.admin", 0)); memberRoles.add(new MemberRole("coretech:role.readers", 0)); store.processSingleTrustedDomainRole(role, prefix, null, memberRoles, accessibleRoles, false); assertEquals(accessibleRoles.size(), 0); }