use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessTrustMembershipNoTrustDomainMatch.
@Test
public void testProcessTrustMembershipNoTrustDomainMatch() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
store.loadZMSPublicKeys();
SignedDomain signedDomain = createSignedDomain("coretech", "weather");
store.processDomain(signedDomain, true);
signedDomain = createTenantSignedDomain("weather", "coretech");
store.processDomain(signedDomain, true);
Set<String> accessibleRoles = new HashSet<>();
String prefix = "coretech" + ROLE_POSTFIX;
String identity = "user_domain.user100";
store.processTrustMembership(store.getCacheStore().getIfPresent("coretech"), identity, prefix, null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 1);
assertTrue(accessibleRoles.contains("tenant.readers"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheNewDomain.
@Test
public void testAddDomainToCacheNewDomain() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
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);
List<Role> roles = new ArrayList<>();
roles.add(role);
DomainData domainData = new DomainData();
domainData.setRoles(roles);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
DomainData domain = store.getDomainData("coretech");
assertNotNull(domain);
assertEquals(domain.getRoles().size(), 1);
assertEquals(domain.getRoles().get(0).getName(), "coretech:role.admin");
assertEquals(domain.getRoles().get(0).getRoleMembers().size(), 1);
assertEquals(domain.getRoles().get(0).getRoleMembers().get(0).getMemberName(), "user_domain.user");
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRoleCheckValuePrefixStart.
@Test
public void testRoleCheckValuePrefixStart() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
String roleCheck = store.roleCheckValue("coretech:role.readers", "coretech:role.");
assertEquals(roleCheck, "coretech:role.readers");
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessDomainServiceIdentitiesNullPolicies.
@Test
public void testProcessDomainServiceIdentitiesNullPolicies() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
DomainData domainData = new DomainData();
domainData.setName("coretech");
dataCache.setDomainData(domainData);
store.processDomainServiceIdentities(domainData, dataCache);
HostServices hostServices = store.getHostServices("host1");
List<String> hosts = hostServices.getNames();
assertNull(hosts);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheUpdatedDomain.
@Test
public void testAddDomainToCacheUpdatedDomain() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
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);
List<Role> roles = new ArrayList<>();
roles.add(role);
DomainData domainData = new DomainData();
domainData.setRoles(roles);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
/* update member list */
role = new Role();
role.setName("coretech:role.admin");
members = new ArrayList<>();
members.add(new RoleMember().setMemberName("user_domain.user1"));
members.add(new RoleMember().setMemberName("user_domain.user2"));
role.setRoleMembers(members);
roles = new ArrayList<>();
roles.add(role);
dataCache = new DataCache();
domainData = new DomainData();
domainData.setRoles(roles);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
DomainData domain = store.getDomainData("coretech");
assertNotNull(domain);
assertEquals(domain.getRoles().size(), 1);
assertEquals(domain.getRoles().get(0).getName(), "coretech:role.admin");
assertEquals(domain.getRoles().get(0).getRoleMembers().size(), 2);
boolean user1 = false;
boolean user2 = false;
for (RoleMember member : domain.getRoles().get(0).getRoleMembers()) {
switch(member.getMemberName()) {
case "user_domain.user1":
user1 = true;
break;
case "user_domain.user2":
user2 = true;
break;
}
}
assertTrue(user1);
assertTrue(user2);
}
Aggregations