use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemovePublicKeysEmpty.
@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"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetAccessibleRolesNoRoles.
@Test
public void testGetAccessibleRolesNoRoles() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
store.loadZMSPublicKeys();
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.nonexistentuser", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 0);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddHostEntriesAddValue.
@Test
public void testAddHostEntriesAddValue() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
List<String> services = new ArrayList<>();
services.add("coretech.storage");
services.add("coretech.backup");
store.hostCache.put("host1", services);
services = new ArrayList<>();
services.add("coretech.storage");
services.add("coretech.backup");
store.hostCache.put("host2", services);
Map<String, Set<String>> hostMap = new HashMap<>();
Set<String> newServices = new HashSet<>();
newServices.add("sports.storage");
hostMap.put("host2", newServices);
hostMap.put("host3", newServices);
store.addHostEntries(hostMap);
assertEquals(store.hostCache.size(), 3);
List<String> retServices = store.hostCache.get("host1");
assertEquals(retServices.size(), 2);
assertTrue(retServices.contains("coretech.storage"));
assertTrue(retServices.contains("coretech.backup"));
retServices = store.hostCache.get("host2");
assertEquals(retServices.size(), 3);
assertTrue(retServices.contains("coretech.storage"));
assertTrue(retServices.contains("coretech.backup"));
assertTrue(retServices.contains("sports.storage"));
retServices = store.hostCache.get("host3");
assertEquals(retServices.size(), 1);
assertTrue(retServices.contains("sports.storage"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemovePublicKeys.
@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"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheUpdatedPublicKeysVersions.
@Test
public void testAddDomainToCacheUpdatedPublicKeysVersions() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
ServiceIdentity service = new ServiceIdentity();
service.setName("coretech.storage");
setServicePublicKey(service, "0", ZTS_Y64_CERT0);
com.yahoo.athenz.zms.PublicKeyEntry publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT1);
publicKey.setId("1");
List<com.yahoo.athenz.zms.PublicKeyEntry> publicKeys = new ArrayList<com.yahoo.athenz.zms.PublicKeyEntry>();
publicKeys.add(publicKey);
service.setPublicKeys(publicKeys);
List<ServiceIdentity> services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
DomainData domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
/* update multiple version public keys */
dataCache = new DataCache();
service = new ServiceIdentity();
service.setName("coretech.storage");
publicKeys = new ArrayList<com.yahoo.athenz.zms.PublicKeyEntry>();
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT0);
publicKey.setId("0");
publicKeys.add(publicKey);
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT3);
publicKey.setId("1");
publicKeys.add(publicKey);
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT2);
publicKey.setId("2");
publicKeys.add(publicKey);
service.setPublicKeys(publicKeys);
services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
assertEquals(store.getPublicKey("coretech", "storage", "0"), ZTS_PEM_CERT0);
assertEquals(store.getPublicKey("coretech", "storage", "1"), ZTS_PEM_CERT3);
assertEquals(store.getPublicKey("coretech", "storage", "2"), ZTS_PEM_CERT2);
assertNull(store.getPublicKey("coretech", "storage", "3"));
}
Aggregations