use of com.yahoo.athenz.common.server.store.ChangeLogStore 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.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemovePublicKeysAll.
@Test
public void testRemovePublicKeysAll() {
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> remKeys = new HashMap<>();
remKeys.put("coretech.storage_0", "PublicKey0");
remKeys.put("sports.storage_0", "PublicKey0");
remKeys.put("sports.storage_1", "PublicKey1");
store.removePublicKeys(remKeys);
assertEquals(store.publicKeyCache.size(), 0);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddPublicKeysUpdateValue.
@Test
public void testAddPublicKeysUpdateValue() {
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.publicKeyCache.size(), 3);
String value = store.publicKeyCache.get("coretech.storage_0");
assertEquals(value, "PublicKey0");
value = store.publicKeyCache.get("sports.storage_0");
assertEquals(value, "PublicKey100");
value = store.publicKeyCache.get("sports.storage_1");
assertEquals(value, "PublicKey101");
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetAccessibleRolesWildCards.
@Test
public void testGetAccessibleRolesWildCards() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
store.loadAthenzPublicKeys();
SignedDomain signedDomain = createSignedDomainWildCardMembers("coretech", "weather");
store.processSignedDomain(signedDomain, true);
Set<String> accessibleRoles = new HashSet<>();
DataCache data = store.getDataCache("coretech");
store.getAccessibleRoles(data, "coretech", "user_domain.user1", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 2);
assertTrue(accessibleRoles.contains("writers"));
assertTrue(accessibleRoles.contains("all"));
accessibleRoles.clear();
store.getAccessibleRoles(data, "coretech", "user_domain.user3", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 3);
assertTrue(accessibleRoles.contains("readers"));
assertTrue(accessibleRoles.contains("writers"));
assertTrue(accessibleRoles.contains("all"));
accessibleRoles.clear();
store.getAccessibleRoles(data, "coretech", "user_domain.user5", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 2);
assertTrue(accessibleRoles.contains("writers"));
assertTrue(accessibleRoles.contains("all"));
accessibleRoles.clear();
store.getAccessibleRoles(data, "coretech", "athenz.service", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 1);
assertTrue(accessibleRoles.contains("all"));
// make sure the prefix is fully matched
accessibleRoles.clear();
store.getAccessibleRoles(data, "coretech", "athenz.use", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 1);
assertTrue(accessibleRoles.contains("all"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore 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));
}
Aggregations