DataStore implements DataCacheProvider, RolesProvider { void removePublicKeys(Map<String, String> publicKeyMap) { if (publicKeyMap == null || publicKeyMap.isEmpty()) { return; } for (Map.Entry<String, String> entry : publicKeyMap.entrySet()) { publicKeyCache.remove(entry.getKey()); } } 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 testRemovePublicKeys() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_1", "PublicKey1"); Map<String, String> remKeys = new HashMap<>(); remKeys.put("sports.storage_0", "PublicKey0"); store.removePublicKeys(remKeys); assertEquals(store.publicKeyCache.size(), 2); assertTrue(store.publicKeyCache.containsKey("coretech.storage_0")); assertTrue(store.publicKeyCache.containsKey("sports.storage_1")); }
@Test public void testRemovePublicKeysAll() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_1", "PublicKey1"); Map<String, String> remKeys = new HashMap<>(); remKeys.put("coretech.storage_0", "PublicKey0"); remKeys.put("sports.storage_0", "PublicKey0"); remKeys.put("sports.storage_1", "PublicKey1"); store.removePublicKeys(remKeys); assertEquals(store.publicKeyCache.size(), 0); }
@Test public void testRemovePublicKeysInvalid() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_1", "PublicKey1"); Map<String, String> remKeys = new HashMap<>(); remKeys.put("sports.storage_2", "PublicKey2"); store.removePublicKeys(remKeys); assertEquals(store.publicKeyCache.size(), 3); assertTrue(store.publicKeyCache.containsKey("coretech.storage_0")); assertTrue(store.publicKeyCache.containsKey("sports.storage_0")); assertTrue(store.publicKeyCache.containsKey("sports.storage_1")); }
@Test public void testRemovePublicKeysEmpty() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); Map<String, String> remKeys = new HashMap<>(); store.removePublicKeys(remKeys); assertEquals(store.publicKeyCache.size(), 1); assertTrue(store.publicKeyCache.containsKey("coretech.storage_0")); }
@Test public void testRemovePublicKeysNull() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); store.removePublicKeys(null); assertEquals(store.publicKeyCache.size(), 1); assertTrue(store.publicKeyCache.containsKey("coretech.storage_0")); }