use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessTrustedDomainDataNull.
@Test
public void testProcessTrustedDomainDataNull() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
Set<String> accessibleRoles = new HashSet<>();
String prefix = "coretech" + ROLE_POSTFIX;
String identity = "user_domain.user1";
String[] requestedRoleList = { "coretech:role.admin" };
Set<String> trustedResources = new HashSet<>();
trustedResources.add("coretech:role.admin");
trustedResources.add("coretech:role.readers");
store.processTrustedDomain(null, identity, prefix, requestedRoleList, trustedResources, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 0);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRoleMatchInSetRegex.
@Test
public void testRoleMatchInSetRegex() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
Set<MemberRole> checkSet = new HashSet<>();
checkSet.add(new MemberRole("coretech:role.readers", 0));
checkSet.add(new MemberRole("coretech:role.writers", 0));
checkSet.add(new MemberRole("*:role.update", 0));
checkSet.add(new MemberRole("weather:role.*", 0));
assertTrue(store.roleMatchInSet("coretech:role.readers", checkSet));
assertTrue(store.roleMatchInSet("coretech:role.writers", checkSet));
assertTrue(store.roleMatchInSet("sports:role.update", checkSet));
assertTrue(store.roleMatchInSet("weather:role.update", checkSet));
assertFalse(store.roleMatchInSet("coretech:role.admin", checkSet));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessDomainServiceIdentities.
@Test
public void testProcessDomainServiceIdentities() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
ServiceIdentity service = new ServiceIdentity();
service.setName("coretech.storage");
List<String> hosts = new ArrayList<>();
hosts.add("host1");
service.setHosts(hosts);
List<ServiceIdentity> services = new ArrayList<>();
services.add(service);
DomainData domainData = new DomainData();
domainData.setName("coretech");
domainData.setServices(services);
DataCache dataCache = new DataCache();
dataCache.setDomainData(domainData);
store.processDomainServiceIdentities(domainData, dataCache);
store.addDomainToCache(domainData.getName(), dataCache);
HostServices hostServices = store.getHostServices("host1");
hosts = hostServices.getNames();
assertEquals(hosts.size(), 1);
assertTrue(hosts.contains("coretech.storage"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessLocalDomainsInvalidLocalDomainRefreshRequired.
@Test
public void testProcessLocalDomainsInvalidLocalDomainRefreshRequired() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore setupStore = new DataStore(clogStore, null, ztsMetric);
setupStore.loadAthenzPublicKeys();
setupStore.processSignedDomain(createSignedDomain("coretech", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("sports", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("mail", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("fantasy", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("profile", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("news", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("politics", "weather"), true);
setupStore.processSignedDomain(createSignedDomain("finance", "weather"), true);
DataStore store = new DataStore(clogStore, null, ztsMetric);
List<String> zmsList = new ArrayList<>(Arrays.asList("coretech", "sports", "mail", "fantasy", "profile", "news", "politics", "finance", "invalid"));
((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(zmsList);
((MockZMSFileChangeLogStore) store.changeLogStore).setRefreshSupport(true);
int badDomains = store.processLocalDomains(zmsList);
assertEquals(badDomains, -1);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheSamePublicKeys.
@Test
public void testAddDomainToCacheSamePublicKeys() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
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<>();
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);
/* same public keys - no changes */
dataCache = new DataCache();
service = new ServiceIdentity();
service.setName("coretech.storage");
publicKeys = new ArrayList<>();
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_CERT1);
publicKey.setId("1");
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_CERT1);
assertNull(store.getPublicKey("coretech", "storage", "2"));
}
Aggregations