Search in sources :

Example 6 with MockZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore 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);
    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"));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity) ArrayList(java.util.ArrayList) DomainData(com.yahoo.athenz.zms.DomainData) HostServices(com.yahoo.athenz.zts.HostServices) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) DataCache(com.yahoo.athenz.zts.cache.DataCache) Test(org.testng.annotations.Test)

Example 7 with MockZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testProcessSignedDomainsNullList.

@Test
public void testProcessSignedDomainsNullList() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null);
    boolean result = store.processSignedDomains(null);
    assertTrue(result);
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 8 with MockZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testRetrieveTagHeadersValueNotFound.

@Test
public void testRetrieveTagHeadersValueNotFound() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null);
    ((MockZMSFileChangeLogStore) store.changeLogStore).setTagHeader(null);
    Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
    List<String> values = new ArrayList<>();
    values.add("Unit-Test");
    responseHeaders.put("User-Agent", values);
    assertNull(((MockZMSFileChangeLogStore) store.changeLogStore).retrieveTagHeader(responseHeaders));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 9 with MockZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testRetrieveTagHeadersEmptyList.

@Test
public void testRetrieveTagHeadersEmptyList() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null);
    ((MockZMSFileChangeLogStore) store.changeLogStore).setTagHeader(null);
    Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
    assertNull(((MockZMSFileChangeLogStore) store.changeLogStore).retrieveTagHeader(responseHeaders));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 10 with MockZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testProcessDomainDeletesZMSSingleDelete.

@Test
public void testProcessDomainDeletesZMSSingleDelete() {
    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("coretech");
    ((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list);
    assertTrue(store.processDomainDeletes());
    assertNull(store.getDomainData("sports"));
    assertNotNull(store.getDomainData("coretech"));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) ArrayList(java.util.ArrayList) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Aggregations

MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)135 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)134 Test (org.testng.annotations.Test)132 HashSet (java.util.HashSet)53 ArrayList (java.util.ArrayList)52 DataCache (com.yahoo.athenz.zts.cache.DataCache)39 SignedDomain (com.yahoo.athenz.zms.SignedDomain)33 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)25 DomainData (com.yahoo.athenz.zms.DomainData)24 HashMap (java.util.HashMap)20 Role (com.yahoo.athenz.zms.Role)13 RoleMember (com.yahoo.athenz.zms.RoleMember)13 ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)11 SignedDomains (com.yahoo.athenz.zms.SignedDomains)11 File (java.io.File)11 HostServices (com.yahoo.athenz.zts.HostServices)9 Set (java.util.Set)7 List (java.util.List)3 ChangeLogStore (com.yahoo.athenz.zts.store.ChangeLogStore)2 DataStore (com.yahoo.athenz.zts.store.DataStore)2