Search in sources :

Example 61 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore 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, ztsMetric);
    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 : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 62 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testRoleMatchInSetRegex.

@Test
public void testRoleMatchInSetRegex() {
    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("coretech:role.readers", 0));
    checkSet.add(new MemberRole("coretech:role.writers", 0));
    checkSet.add(new MemberRole("*:role.update", 0));
    checkSet.add(new MemberRole("weather:role.*", 0));
    assertTrue(store.roleMatchInSet("coretech:role.readers", checkSet));
    assertTrue(store.roleMatchInSet("coretech:role.writers", checkSet));
    assertTrue(store.roleMatchInSet("sports:role.update", checkSet));
    assertTrue(store.roleMatchInSet("weather:role.update", checkSet));
    assertFalse(store.roleMatchInSet("coretech:role.admin", checkSet));
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 63 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore 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, ztsMetric);
    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 : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) HostServices(com.yahoo.athenz.zts.HostServices) DataCache(com.yahoo.athenz.zts.cache.DataCache) Test(org.testng.annotations.Test)

Example 64 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testProcessLocalDomainsInvalidLocalDomainRefreshRequired.

@Test
public void testProcessLocalDomainsInvalidLocalDomainRefreshRequired() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore setupStore = new DataStore(clogStore, null, ztsMetric);
    setupStore.loadAthenzPublicKeys();
    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);
    ((MockZMSFileChangeLogStore) store.changeLogStore).setRefreshSupport(true);
    int badDomains = store.processLocalDomains(zmsList);
    assertEquals(badDomains, -1);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 65 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testAddDomainToCacheSamePublicKeys.

@Test
public void testAddDomainToCacheSamePublicKeys() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    DataCache dataCache = new DataCache();
    ServiceIdentity service = new ServiceIdentity();
    service.setName("coretech.storage");
    setServicePublicKey(service, "0", ZTS_Y64_CERT0);
    com.yahoo.athenz.zms.PublicKeyEntry publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
    publicKey.setKey(ZTS_Y64_CERT1);
    publicKey.setId("1");
    List<com.yahoo.athenz.zms.PublicKeyEntry> publicKeys = new ArrayList<>();
    publicKeys.add(publicKey);
    service.setPublicKeys(publicKeys);
    List<ServiceIdentity> services = new ArrayList<>();
    services.add(service);
    dataCache.processServiceIdentity(service);
    DomainData domainData = new DomainData();
    domainData.setServices(services);
    dataCache.setDomainData(domainData);
    store.addDomainToCache("coretech", dataCache);
    /* same public keys - no changes */
    dataCache = new DataCache();
    service = new ServiceIdentity();
    service.setName("coretech.storage");
    publicKeys = new ArrayList<>();
    publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
    publicKey.setKey(ZTS_Y64_CERT0);
    publicKey.setId("0");
    publicKeys.add(publicKey);
    publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
    publicKey.setKey(ZTS_Y64_CERT1);
    publicKey.setId("1");
    publicKeys.add(publicKey);
    service.setPublicKeys(publicKeys);
    services = new ArrayList<>();
    services.add(service);
    dataCache.processServiceIdentity(service);
    domainData = new DomainData();
    domainData.setServices(services);
    dataCache.setDomainData(domainData);
    store.addDomainToCache("coretech", dataCache);
    assertEquals(store.getPublicKey("coretech", "storage", "0"), ZTS_PEM_CERT0);
    assertEquals(store.getPublicKey("coretech", "storage", "1"), ZTS_PEM_CERT1);
    assertNull(store.getPublicKey("coretech", "storage", "2"));
}
Also used : com.yahoo.athenz.zms(com.yahoo.athenz.zms) DataCache(com.yahoo.athenz.zts.cache.DataCache) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Aggregations

ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)262 Test (org.testng.annotations.Test)258 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.MockZMSFileChangeLogStore)107 ZMSFileChangeLogStore (com.yahoo.athenz.common.server.store.impl.ZMSFileChangeLogStore)106 DataStore (com.yahoo.athenz.zts.store.DataStore)106 Path (java.nio.file.Path)71 InstanceCertManager (com.yahoo.athenz.zts.cert.InstanceCertManager)57 DataCache (com.yahoo.athenz.zts.cache.DataCache)41 InstanceProvider (com.yahoo.athenz.instance.provider.InstanceProvider)40 X509Certificate (java.security.cert.X509Certificate)35 InstanceConfirmation (com.yahoo.athenz.instance.provider.InstanceConfirmation)34 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)27 X509CertRecord (com.yahoo.athenz.common.server.cert.X509CertRecord)23 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 HttpServletResponse (javax.servlet.http.HttpServletResponse)17 Response (javax.ws.rs.core.Response)17 Principal (com.yahoo.athenz.auth.Principal)16 MockStatusCheckerNoException (com.yahoo.athenz.zts.status.MockStatusCheckerNoException)12 File (java.io.File)12 IOException (java.io.IOException)12