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);
}
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"));
}
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());
}
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);
}
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);
}
Aggregations