Search in sources :

Example 46 with ChangeLogStore

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

the class DataStoreTest method testProcessTrustedDomainMemberRoleNotValid.

@Test
public void testProcessTrustedDomainMemberRoleNotValid() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    DataCache dataCache = createDataCache("coretech");
    Set<String> accessibleRoles = new HashSet<>();
    String prefix = "coretech" + ROLE_POSTFIX;
    String identity = "user_domain.user1";
    String[] requestedRoleList = { "coretech:role.writers" };
    /* invalid role causing no match */
    Set<String> trustedResources = new HashSet<>();
    trustedResources.add("coretech:role.admin");
    trustedResources.add("coretech:role.readers");
    store.processTrustedDomain(dataCache, identity, prefix, requestedRoleList, trustedResources, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 0);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) DataCache(com.yahoo.athenz.zts.cache.DataCache) Test(org.testng.annotations.Test)

Example 47 with ChangeLogStore

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

the class DataStoreTest method testProcessTrustMembershipNoTrustDomainNoMatch.

@Test
public void testProcessTrustMembershipNoTrustDomainNoMatch() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.loadAthenzPublicKeys();
    SignedDomain signedDomain = createSignedDomain("coretech", "weather");
    store.processSignedDomain(signedDomain, true);
    signedDomain = createTenantSignedDomain("weather", "coretech");
    store.processSignedDomain(signedDomain, true);
    Set<String> accessibleRoles = new HashSet<>();
    String prefix = "coretech" + ROLE_POSTFIX;
    String identity = "user_domain.user400";
    store.processTrustMembership(store.getCacheStore().getIfPresent("coretech"), identity, prefix, null, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 0);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 48 with ChangeLogStore

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

Example 49 with ChangeLogStore

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

the class DataStoreTest method testGetAccessibleRolesSpecifiedRole.

@Test
public void testGetAccessibleRolesSpecifiedRole() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.loadAthenzPublicKeys();
    SignedDomain signedDomain = createSignedDomain("coretech", "weather");
    store.processSignedDomain(signedDomain, true);
    Set<String> accessibleRoles = new HashSet<>();
    DataCache data = store.getDataCache("coretech");
    String[] requestedRoleList = { "coretech:role.admin" };
    store.getAccessibleRoles(data, "coretech", "user_domain.user", requestedRoleList, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 1);
    assertTrue(accessibleRoles.contains("admin"));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) DataCache(com.yahoo.athenz.zts.cache.DataCache) Test(org.testng.annotations.Test)

Example 50 with ChangeLogStore

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

the class DataStoreTest method testAddDomainToCacheUpdatedPublicKeysVersions.

@Test
public void testAddDomainToCacheUpdatedPublicKeysVersions() {
    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);
    /* update multiple version public keys */
    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_CERT3);
    publicKey.setId("1");
    publicKeys.add(publicKey);
    publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
    publicKey.setKey(ZTS_Y64_CERT2);
    publicKey.setId("2");
    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_CERT3);
    assertEquals(store.getPublicKey("coretech", "storage", "2"), ZTS_PEM_CERT2);
    assertNull(store.getPublicKey("coretech", "storage", "3"));
}
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