use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessSignedDomainsInvalidDomainWithSuccess.
@Test
public void testProcessSignedDomainsInvalidDomainWithSuccess() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
List<SignedDomain> list = new ArrayList<>();
// if we have one successful domain and one failure
// then our result is going to be success
SignedDomain signedDomain = createSignedDomain("coretech", "weather");
list.add(signedDomain);
signedDomain = createSignedDomain("sports", "weather");
signedDomain.setSignature("Invalid0");
list.add(signedDomain);
SignedDomains signedDomains = new SignedDomains();
signedDomains.setDomains(list);
boolean result = store.processSignedDomains(signedDomains);
assertTrue(result);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessDomainDeletesZMSAllDelete.
@Test
public void testProcessDomainDeletesZMSAllDelete() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
addDomainToDataStore(store, "coretech");
addDomainToDataStore(store, "sports");
List<String> list = new ArrayList<>();
list.add(userDomain);
list.add("sys.auth");
list.add("coretech2");
list.add("sports2");
((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list);
assertTrue(store.processDomainDeletes());
assertNull(store.getDomainData("sports"));
assertNull(store.getDomainData("coretech"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore 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);
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.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testSaveLastModificationTime.
@Test
public void testSaveLastModificationTime() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
store.changeLogStore.setLastModificationTimestamp("23456");
String data = null;
File f = new File("/tmp/zts_server_unit_tests/zts_root/.lastModTime");
try {
data = new String(Files.readAllBytes(f.toPath()), "UTF-8");
} catch (IOException e) {
fail();
}
assertEquals(data, "{\"lastModTime\":\"23456\"}");
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemoveHostEntriesRemoveValue.
@Test
public void testRemoveHostEntriesRemoveValue() {
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("coretech.storage");
hostMap.put("host1", newServices);
newServices = new HashSet<>();
newServices.add("coretech.backup");
hostMap.put("host2", newServices);
store.removeHostEntries(hostMap);
assertEquals(store.hostCache.size(), 2);
List<String> retServices = store.hostCache.get("host1");
assertEquals(retServices.size(), 1);
assertTrue(retServices.contains("coretech.backup"));
retServices = store.hostCache.get("host2");
assertEquals(retServices.size(), 1);
assertTrue(retServices.contains("coretech.storage"));
}
Aggregations