Search in sources :

Example 26 with MockZMSFileChangeLogStore

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"));
}
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) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 27 with MockZMSFileChangeLogStore

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);
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) 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 28 with MockZMSFileChangeLogStore

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

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

Example 30 with MockZMSFileChangeLogStore

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