DataStore implements DataCacheProvider, RolesProvider { boolean processSignedDomains(SignedDomains signedDomains) { if (signedDomains == null) { if (LOGGER.isInfoEnabled()) { LOGGER.info("No updates received from ZMS Server"); } return true; } List<SignedDomain> domains = signedDomains.getDomains(); if (domains == null || domains.isEmpty()) { if (LOGGER.isInfoEnabled()) { LOGGER.info("No updates received from ZMS Server"); } return true; } boolean result = false; for (SignedDomain domain : domains) { if (processDomain(domain, true)) { result = true; } } return result; } 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 testProcessSignedDomains() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<SignedDomain> list = new ArrayList<>(); SignedDomain signedDomain = createSignedDomain("coretech", "weather"); list.add(signedDomain); signedDomain = createSignedDomain("sports", "weather"); list.add(signedDomain); SignedDomains signedDomains = new SignedDomains(); signedDomains.setDomains(list); boolean result = store.processSignedDomains(signedDomains); assertTrue(result); assertNotNull(store.getDomainData("coretech")); assertNotNull(store.getDomainData("sports")); }
@Test public void testProcessSignedDomainsNullList() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); boolean result = store.processSignedDomains(null); assertTrue(result); }
@Test public void testProcessSignedDomainsEmptyList() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); SignedDomains signedDomains = new SignedDomains(); signedDomains.setDomains(null); boolean result = store.processSignedDomains(signedDomains); assertTrue(result); }
@Test public void testProcessSignedDomainsInvalidDomainWithSuccess() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<SignedDomain> list = new ArrayList<>(); SignedDomain signedDomain = createSignedDomain("coretech", "weather"); list.add(signedDomain); signedDomain = createSignedDomain("sports", "weather"); signedDomain.setSignature("Invalid0"); list.add(signedDomain); SignedDomains signedDomains = new SignedDomains(); signedDomains.setDomains(list); boolean result = store.processSignedDomains(signedDomains); assertTrue(result); }
@Test public void testProcessSignedDomainsAllInvalidDomain() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<SignedDomain> list = new ArrayList<>(); SignedDomain signedDomain = createSignedDomain("sports", "weather"); signedDomain.setSignature("Invalid0"); list.add(signedDomain); SignedDomains signedDomains = new SignedDomains(); signedDomains.setDomains(list); boolean result = store.processSignedDomains(signedDomains); assertFalse(result); }