use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessGroupDeletedMembersNull.
@Test
public void testProcessGroupDeletedMembersNull() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
store.loadAthenzPublicKeys();
// if we pass null for the members then we return right
// away so sno exceptions even if we pass null for the group name
store.processGroupDeletedMembers(null, null);
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method DataStorContstructorTest.
@Test
public void DataStorContstructorTest() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
assertNotNull(store);
assertEquals(store.delDomainRefreshTime, 3600);
assertEquals(store.updDomainRefreshTime, 60);
System.setProperty("athenz.zts.zms_domain_update_timeout", "60");
System.setProperty("athenz.zts.zms_domain_delete_timeout", "50");
System.setProperty("athenz.zts.zms_domain_check_timeout", "45");
store = new DataStore(clogStore, null, ztsMetric);
assertNotNull(store);
assertEquals(store.delDomainRefreshTime, 60);
assertEquals(store.updDomainRefreshTime, 60);
assertEquals(store.checkDomainRefreshTime, 60);
System.clearProperty("athenz.zts.zms_domain_update_timeout");
System.clearProperty("athenz.zts.zms_domain_delete_timeout");
System.clearProperty("athenz.zts.zms_domain_check_timeout");
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessDomainPoliciesInactive.
@Test
public void testProcessDomainPoliciesInactive() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
List<com.yahoo.athenz.zms.Policy> policies = new ArrayList<>();
com.yahoo.athenz.zms.Policy policy = new com.yahoo.athenz.zms.Policy();
policy.setActive(false);
com.yahoo.athenz.zms.Assertion assertion = new com.yahoo.athenz.zms.Assertion();
assertion.setResource("sports:role.readers");
assertion.setAction("assume_role");
assertion.setRole("coretech:role.readers");
List<com.yahoo.athenz.zms.Assertion> assertions = new ArrayList<>();
assertions.add(assertion);
policy.setAssertions(assertions);
policies.add(policy);
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);
roles.add(role);
role = new Role();
role.setName("coretech:role.readers");
members = new ArrayList<>();
members.add(new RoleMember().setMemberName("user_domain.user"));
role.setRoleMembers(members);
roles.add(role);
com.yahoo.athenz.zms.DomainPolicies domainPolicies = new com.yahoo.athenz.zms.DomainPolicies();
domainPolicies.setDomain("coretech");
domainPolicies.setPolicies(policies);
com.yahoo.athenz.zms.SignedPolicies signedPolicies = new com.yahoo.athenz.zms.SignedPolicies();
signedPolicies.setContents(domainPolicies);
signedPolicies.setSignature(Crypto.sign(SignUtils.asCanonicalString(domainPolicies), pkey));
signedPolicies.setKeyId("0");
DomainData domainData = new DomainData();
domainData.setName("coretech");
domainData.setPolicies(signedPolicies);
domainData.setRoles(roles);
DataCache dataCache = new DataCache();
dataCache.setDomainData(domainData);
store.processDomainPolicies(domainData, dataCache);
// we should not get any members
assertNull(dataCache.getMemberRoleSet("user_domain.user"));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessJWSDomainsNullList.
@Test
public void testProcessJWSDomainsNullList() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null, ztsMetric);
store.jwsDomainSupport = true;
assertTrue(store.processJWSDomains(null));
}
use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetPublicKeyUpdated.
@Test
public void testGetPublicKeyUpdated() {
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.getPublicKey("coretech", "storage", "0"), "PublicKey0");
assertEquals(store.getPublicKey("sports", "storage", "0"), "PublicKey100");
assertEquals(store.getPublicKey("sports", "storage", "1"), "PublicKey101");
}
Aggregations