Search in sources :

Example 1 with MemberRole

use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.

the class DataStoreTest method testProcessSingleTrustedDomainRoleAddRoleFalse.

@Test
public void testProcessSingleTrustedDomainRoleAddRoleFalse() {
    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 = "coretech2" + ROLE_POSTFIX;
    String role = "coretech:role.readers";
    /* invalid role causing no match */
    Set<MemberRole> memberRoles = new HashSet<>();
    memberRoles.add(new MemberRole("coretech:role.admin", 0));
    memberRoles.add(new MemberRole("coretech:role.readers", 0));
    store.processSingleTrustedDomainRole(role, prefix, null, memberRoles, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 0);
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 2 with MemberRole

use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.

the class DataStoreTest method testProcessStandardMembershipRoleCheckNull.

@Test
public void testProcessStandardMembershipRoleCheckNull() {
    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;
    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, null, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 2);
    assertTrue(accessibleRoles.contains("admin"));
    assertTrue(accessibleRoles.contains("readers"));
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 3 with MemberRole

use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.

the class DataStoreTest method testProcessStandardMembershipRoleExpired.

@Test
public void testProcessStandardMembershipRoleExpired() {
    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[] requestedRoleList = { "coretech:role.admin" };
    Set<MemberRole> memberRoles = new HashSet<>();
    memberRoles.add(new MemberRole("coretech:role.admin", System.currentTimeMillis() - 1000));
    memberRoles.add(new MemberRole("coretech:role.readers", 0));
    store.processStandardMembership(memberRoles, prefix, requestedRoleList, accessibleRoles, false);
    assertTrue(accessibleRoles.isEmpty());
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 4 with MemberRole

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

Example 5 with MemberRole

use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.

the class DataStoreTest method testProcessSingleTrustedDomainRoleNoMatchInSet.

@Test
public void testProcessSingleTrustedDomainRoleNoMatchInSet() {
    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 role = "coretech:role.writers";
    /* invalid role causing no match */
    Set<MemberRole> memberRoles = new HashSet<>();
    memberRoles.add(new MemberRole("coretech:role.admin", 0));
    memberRoles.add(new MemberRole("coretech:role.readers", 0));
    store.processSingleTrustedDomainRole(role, prefix, null, memberRoles, accessibleRoles, false);
    assertEquals(accessibleRoles.size(), 0);
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Aggregations

MemberRole (com.yahoo.athenz.zts.cache.MemberRole)18 ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)16 Test (org.testng.annotations.Test)16 DataCache (com.yahoo.athenz.zts.cache.DataCache)4 com.yahoo.athenz.zms (com.yahoo.athenz.zms)1