use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemoveHostEntrieNullMap.
@Test
public void testRemoveHostEntrieNullMap() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
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);
store.removeHostEntries(null);
assertEquals(store.hostCache.size(), 2);
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(), 2);
assertTrue(retServices.contains("coretech.storage"));
assertTrue(retServices.contains("coretech.backup"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddHostEntrieNullMap.
@Test
public void testAddHostEntrieNullMap() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
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);
store.addHostEntries(null);
assertEquals(store.hostCache.size(), 2);
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(), 2);
assertTrue(retServices.contains("coretech.storage"));
assertTrue(retServices.contains("coretech.backup"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetAccessibleRolesInvalidDomain.
@Test
public void testGetAccessibleRolesInvalidDomain() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
SignedDomain signedDomain = createSignedDomain("coretech", "weather");
store.processSignedDomain(signedDomain, true);
Set<String> accessibleRoles = new HashSet<>();
DataCache data = store.getDataCache("sports");
store.getAccessibleRoles(data, "sports", "user_domain.user", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 0);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessTrustedDomainRoleValidWildCard.
@Test
public void testProcessTrustedDomainRoleValidWildCard() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
DataCache dataCache = createDataCacheWildCard("coretech");
// first we're going tor process user1
// which should match all three roles including
// both wildcard roles
Set<String> accessibleRoles = new HashSet<>();
String prefix = "coretech" + ROLE_POSTFIX;
String identity = "user_domain.user1";
Set<String> trustedResources = new HashSet<>();
trustedResources.add("coretech:role.admin");
trustedResources.add("coretech:role.readers");
trustedResources.add("coretech:role.editors");
store.processTrustedDomain(dataCache, identity, prefix, null, trustedResources, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 3);
assertTrue(accessibleRoles.contains("admin"));
assertTrue(accessibleRoles.contains("editors"));
assertTrue(accessibleRoles.contains("readers"));
// user_domain.joe should match readers and editors
accessibleRoles.clear();
identity = "user_domain.joe";
store.processTrustedDomain(dataCache, identity, prefix, null, trustedResources, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 2);
assertTrue(accessibleRoles.contains("readers"));
assertTrue(accessibleRoles.contains("editors"));
// random service should only match editors
accessibleRoles.clear();
identity = "athenz.service";
store.processTrustedDomain(dataCache, identity, prefix, null, trustedResources, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 1);
assertTrue(accessibleRoles.contains("editors"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore 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, ztsMetric);
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"));
}
Aggregations