use of com.yahoo.athenz.zms.DomainData in project athenz by yahoo.
the class DataStoreTest method testDeleteDomain.
@Test
public void testDeleteDomain() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
SignedDomain signedDomain = new SignedDomain();
List<Role> roles = new ArrayList<>();
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);
DomainData domainData = new DomainData();
domainData.setName("coretech");
domainData.setRoles(roles);
signedDomain.setDomain(domainData);
signedDomain.setKeyId("0");
((MockZMSFileChangeLogStore) store.changeLogStore).put("coretech", JSON.bytes(signedDomain));
DataCache dataCache = new DataCache();
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
store.deleteDomainFromCache("coretech");
store.changeLogStore.removeLocalDomain("coretech");
assertNull(store.getCacheStore().getIfPresent("coretech"));
File file = new File("/tmp/zts_server_unit_tests/zts_root/coretech");
assertFalse(file.exists());
}
use of com.yahoo.athenz.zms.DomainData in project athenz by yahoo.
the class DataStoreTest method testProcessDomainPoliciesNullPolicies.
@Test
public void testProcessDomainPoliciesNullPolicies() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DomainData domainData = new DomainData();
domainData.setName("coretech");
DataCache dataCache = new DataCache();
dataCache.setDomainData(domainData);
store.processDomainPolicies(domainData, dataCache);
assertEquals(dataCache.getMemberCount(), 0);
}
use of com.yahoo.athenz.zms.DomainData in project athenz by yahoo.
the class DataStoreTest method addDomainToDataStore.
private void addDomainToDataStore(DataStore store, String domainName) {
SignedDomain signedDomain = new SignedDomain();
Role role = new Role();
role.setName(domainName + ":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.setName(domainName);
domainData.setRoles(roles);
signedDomain.setDomain(domainData);
signedDomain.setKeyId("0");
((MockZMSFileChangeLogStore) store.changeLogStore).put(domainName, JSON.bytes(signedDomain));
DataCache dataCache = new DataCache();
dataCache.setDomainData(domainData);
store.addDomainToCache(domainName, dataCache);
}
use of com.yahoo.athenz.zms.DomainData in project athenz by yahoo.
the class ZMSFileChangeLogStoreTest method getSignedDomainList.
@Test
public void getSignedDomainList() {
ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
ZMSClient zmsClient = Mockito.mock(ZMSClient.class);
List<SignedDomain> domains = new ArrayList<>();
DomainData domData = new DomainData().setName("athenz");
SignedDomain domain = new SignedDomain().setDomain(domData);
domains.add(domain);
SignedDomains domainList = new SignedDomains().setDomains(domains);
Mockito.when(zmsClient.getSignedDomains("athenz", null, null, null)).thenReturn(domainList);
List<SignedDomain> returnList = fstore.getSignedDomainList(zmsClient, domainList);
assertEquals(returnList.size(), 1);
assertEquals(returnList.get(0).getDomain().getName(), "athenz");
}
Aggregations