use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessLocalDomainsInvalidLocalDomainBelowThreshold.
@Test
public void testProcessLocalDomainsInvalidLocalDomainBelowThreshold() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore setupStore = new DataStore(clogStore, null, ztsMetric);
setupStore.loadAthenzPublicKeys();
// create 8 records so our 1/4 threashold for bad domains is 2
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);
int badDomains = store.processLocalDomains(zmsList);
assertEquals(badDomains, 1);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class ChangeLogStoreTest method testChangeLogStore.
@Test
public void testChangeLogStore() {
ChangeLogStore store = new ChangeLogStore() {
@Override
public SignedDomain getLocalSignedDomain(String domainName) {
return null;
}
@Override
public SignedDomain getServerSignedDomain(String domainName) {
return null;
}
@Override
public void removeLocalDomain(String domainName) {
}
@Override
public void saveLocalDomain(String domainName, SignedDomain signedDomain) {
}
@Override
public List<String> getLocalDomainList() {
return null;
}
@Override
public Set<String> getServerDomainList() {
return null;
}
@Override
public SignedDomains getServerDomainModifiedList() {
return null;
}
@Override
public SignedDomains getUpdatedSignedDomains(StringBuilder lastModTimeBuffer) {
return null;
}
@Override
public void setLastModificationTimestamp(String lastModTime) {
}
@Override
public boolean supportsFullRefresh() {
return false;
}
};
assertNull(store.getLocalJWSDomain("domain"));
assertNull(store.getServerJWSDomain("domain"));
assertNull(store.getUpdatedJWSDomains(null));
store.saveLocalDomain("domain", new JWSDomain());
store.setRequestConditions(true);
store.setRequestConditions(false);
store.setJWSDomainSupport(true);
store.setJWSDomainSupport(false);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessLocalDomainInvalidFile.
@Test
public void testProcessLocalDomainInvalidFile() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
assertFalse(store.processLocalDomain("coretech"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRoleMatchInSetExpiration.
@Test
public void testRoleMatchInSetExpiration() {
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("expired", System.currentTimeMillis() - 100000));
checkSet.add(new MemberRole("notexpired", System.currentTimeMillis() + 100000));
assertFalse(store.roleMatchInSet("expired", checkSet));
assertTrue(store.roleMatchInSet("notexpired", checkSet));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore 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, ztsMetric);
setupStore.loadAthenzPublicKeys();
SignedDomain signedDomain = createSignedDomain("coretech", "weather");
setupStore.processSignedDomain(signedDomain, true);
signedDomain = createSignedDomain("sports", "weather");
setupStore.processSignedDomain(signedDomain, true);
DataStore store = new DataStore(clogStore, null, ztsMetric);
List<String> list = new ArrayList<>();
list.add("coretech");
list.add("sports");
((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list);
int badDomains = store.processLocalDomains(list);
assertEquals(badDomains, 0);
assertNotNull(store.getDomainData("coretech"));
assertNotNull(store.getDomainData("sports"));
}
Aggregations