use of com.yahoo.athenz.zts.cache.MemberRole 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));
}
use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.
the class DataStoreTest method testRoleMatchInSetRegex.
@Test
public void testRoleMatchInSetRegex() {
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("coretech:role.readers", 0));
checkSet.add(new MemberRole("coretech:role.writers", 0));
checkSet.add(new MemberRole("*:role.update", 0));
checkSet.add(new MemberRole("weather:role.*", 0));
assertTrue(store.roleMatchInSet("coretech:role.readers", checkSet));
assertTrue(store.roleMatchInSet("coretech:role.writers", checkSet));
assertTrue(store.roleMatchInSet("sports:role.update", checkSet));
assertTrue(store.roleMatchInSet("weather:role.update", checkSet));
assertFalse(store.roleMatchInSet("coretech:role.admin", checkSet));
}
use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.
the class DataStoreTest method testProcessSingleTrustedDomainRoleAddRoleTrue.
@Test
public void testProcessSingleTrustedDomainRoleAddRoleTrue() {
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.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);
assertTrue(accessibleRoles.contains("readers"));
}
use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.
the class DataStoreTest method testRoleMatchInSetPlain.
@Test
public void testRoleMatchInSetPlain() {
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("writers", 0));
checkSet.add(new MemberRole("readers", 0));
assertTrue(store.roleMatchInSet("writers", checkSet));
assertTrue(store.roleMatchInSet("readers", checkSet));
assertFalse(store.roleMatchInSet("admin", checkSet));
assertFalse(store.roleMatchInSet("testwriters", checkSet));
assertFalse(store.roleMatchInSet("writerstest", checkSet));
}
use of com.yahoo.athenz.zts.cache.MemberRole in project athenz by yahoo.
the class DataStoreTest method testProcessStandardMembershipRoleSuffixInValid.
@Test
public void testProcessStandardMembershipRoleSuffixInValid() {
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 = { "2admin" };
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(), 0);
}
Aggregations