Search in sources :

Example 51 with ChangeLogStore

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);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 52 with ChangeLogStore

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);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) JWSDomain(com.yahoo.athenz.zms.JWSDomain) SignedDomain(com.yahoo.athenz.zms.SignedDomain) Test(org.testng.annotations.Test)

Example 53 with ChangeLogStore

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"));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 54 with ChangeLogStore

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));
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 55 with ChangeLogStore

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