use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessLocalDomains.
@Test
public void testProcessLocalDomains() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore setupStore = new DataStore(clogStore, null);
setupStore.loadZMSPublicKeys();
SignedDomain signedDomain = createSignedDomain("coretech", "weather");
setupStore.processDomain(signedDomain, true);
signedDomain = createSignedDomain("sports", "weather");
setupStore.processDomain(signedDomain, true);
DataStore store = new DataStore(clogStore, null);
List<String> list = new ArrayList<>();
list.add("coretech");
list.add("sports");
((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list);
boolean result = store.processLocalDomains(list);
assertTrue(result);
assertNotNull(store.getDomainData("coretech"));
assertNotNull(store.getDomainData("sports"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessStandardMembershipRoleValid.
@Test
public void testProcessStandardMembershipRoleValid() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
Set<String> accessibleRoles = new HashSet<>();
String prefix = "coretech" + ROLE_POSTFIX;
String[] requestedRoleList = { "coretech:role.admin" };
Set<MemberRole> memberRoles = new HashSet<>();
memberRoles.add(new MemberRole("coretech:role.admin", 0));
memberRoles.add(new MemberRole("coretech:role.readers", 0));
store.processStandardMembership(memberRoles, prefix, requestedRoleList, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 1);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore 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);
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.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemovePublicKeysAll.
@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);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddPublicKeysUpdateValue.
@Test
public void testAddPublicKeysUpdateValue() {
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> addKeys = new HashMap<>();
addKeys.put("coretech.storage_0", "PublicKey0");
addKeys.put("sports.storage_0", "PublicKey100");
addKeys.put("sports.storage_1", "PublicKey101");
store.addPublicKeys(addKeys);
assertEquals(store.publicKeyCache.size(), 3);
String value = store.publicKeyCache.get("coretech.storage_0");
assertEquals(value, "PublicKey0");
value = store.publicKeyCache.get("sports.storage_0");
assertEquals(value, "PublicKey100");
value = store.publicKeyCache.get("sports.storage_1");
assertEquals(value, "PublicKey101");
}
Aggregations