Search in sources :

Example 66 with MockZMSFileChangeLogStore

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);
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) SignedDomain(com.yahoo.athenz.zms.SignedDomain) ArrayList(java.util.ArrayList) SignedDomains(com.yahoo.athenz.zms.SignedDomains) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 67 with MockZMSFileChangeLogStore

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"));
}
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)

Example 68 with MockZMSFileChangeLogStore

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);
}
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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 69 with MockZMSFileChangeLogStore

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\"}");
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) IOException(java.io.IOException) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) File(java.io.File) Test(org.testng.annotations.Test)

Example 70 with MockZMSFileChangeLogStore

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"));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) HashSet(java.util.HashSet) 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