Search in sources :

Example 1 with ChangeLogStore

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

the class DataStoreTest method testProcessGroupDeletedMembersNull.

@Test
public void testProcessGroupDeletedMembersNull() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.loadAthenzPublicKeys();
    // if we pass null for the members then we return right
    // away so sno exceptions even if we pass null for the group name
    store.processGroupDeletedMembers(null, null);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 2 with ChangeLogStore

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

the class DataStoreTest method DataStorContstructorTest.

@Test
public void DataStorContstructorTest() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    assertNotNull(store);
    assertEquals(store.delDomainRefreshTime, 3600);
    assertEquals(store.updDomainRefreshTime, 60);
    System.setProperty("athenz.zts.zms_domain_update_timeout", "60");
    System.setProperty("athenz.zts.zms_domain_delete_timeout", "50");
    System.setProperty("athenz.zts.zms_domain_check_timeout", "45");
    store = new DataStore(clogStore, null, ztsMetric);
    assertNotNull(store);
    assertEquals(store.delDomainRefreshTime, 60);
    assertEquals(store.updDomainRefreshTime, 60);
    assertEquals(store.checkDomainRefreshTime, 60);
    System.clearProperty("athenz.zts.zms_domain_update_timeout");
    System.clearProperty("athenz.zts.zms_domain_delete_timeout");
    System.clearProperty("athenz.zts.zms_domain_check_timeout");
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 3 with ChangeLogStore

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

the class DataStoreTest method testProcessDomainPoliciesInactive.

@Test
public void testProcessDomainPoliciesInactive() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    List<com.yahoo.athenz.zms.Policy> policies = new ArrayList<>();
    com.yahoo.athenz.zms.Policy policy = new com.yahoo.athenz.zms.Policy();
    policy.setActive(false);
    com.yahoo.athenz.zms.Assertion assertion = new com.yahoo.athenz.zms.Assertion();
    assertion.setResource("sports:role.readers");
    assertion.setAction("assume_role");
    assertion.setRole("coretech:role.readers");
    List<com.yahoo.athenz.zms.Assertion> assertions = new ArrayList<>();
    assertions.add(assertion);
    policy.setAssertions(assertions);
    policies.add(policy);
    List<Role> roles = new ArrayList<>();
    Role role = new Role();
    role.setName("coretech:role.admin");
    List<RoleMember> members = new ArrayList<>();
    members.add(new RoleMember().setMemberName("user_domain.user"));
    role.setRoleMembers(members);
    roles.add(role);
    role = new Role();
    role.setName("coretech:role.readers");
    members = new ArrayList<>();
    members.add(new RoleMember().setMemberName("user_domain.user"));
    role.setRoleMembers(members);
    roles.add(role);
    com.yahoo.athenz.zms.DomainPolicies domainPolicies = new com.yahoo.athenz.zms.DomainPolicies();
    domainPolicies.setDomain("coretech");
    domainPolicies.setPolicies(policies);
    com.yahoo.athenz.zms.SignedPolicies signedPolicies = new com.yahoo.athenz.zms.SignedPolicies();
    signedPolicies.setContents(domainPolicies);
    signedPolicies.setSignature(Crypto.sign(SignUtils.asCanonicalString(domainPolicies), pkey));
    signedPolicies.setKeyId("0");
    DomainData domainData = new DomainData();
    domainData.setName("coretech");
    domainData.setPolicies(signedPolicies);
    domainData.setRoles(roles);
    DataCache dataCache = new DataCache();
    dataCache.setDomainData(domainData);
    store.processDomainPolicies(domainData, dataCache);
    // we should not get any members
    assertNull(dataCache.getMemberRoleSet("user_domain.user"));
}
Also used : com.yahoo.athenz.zms(com.yahoo.athenz.zms) DataCache(com.yahoo.athenz.zts.cache.DataCache) MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 4 with ChangeLogStore

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

the class DataStoreTest method testProcessJWSDomainsNullList.

@Test
public void testProcessJWSDomainsNullList() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.jwsDomainSupport = true;
    assertTrue(store.processJWSDomains(null));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 5 with ChangeLogStore

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

the class DataStoreTest method testGetPublicKeyUpdated.

@Test
public void testGetPublicKeyUpdated() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    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.getPublicKey("coretech", "storage", "0"), "PublicKey0");
    assertEquals(store.getPublicKey("sports", "storage", "0"), "PublicKey100");
    assertEquals(store.getPublicKey("sports", "storage", "1"), "PublicKey101");
}
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