use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetAccessibleRolesMultipleRoles.
@Test
public void testGetAccessibleRolesMultipleRoles() {
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);
Set<String> accessibleRoles = new HashSet<>();
DataCache data = store.getDataCache("coretech");
store.getAccessibleRoles(data, "coretech", "user_domain.user", null, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 2);
assertTrue(accessibleRoles.contains("admin"));
assertTrue(accessibleRoles.contains("writers"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testGetPublicKeyInvalid.
@Test
public void testGetPublicKeyInvalid() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
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("sports.storage_1", "PublicKey1");
addKeys.put("sports.storage_2", "PublicKey2");
store.addPublicKeys(addKeys);
assertNull(store.getPublicKey("weather", "storage", "0"));
assertNull(store.getPublicKey("sports", "storage", "101"));
assertNull(store.getPublicKey("sports", "backup", "0"));
assertNull(store.getPublicKey("sports", "storage", "-1"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheRemovedPublicKeysV0.
@Test
public void testAddDomainToCacheRemovedPublicKeysV0() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
ServiceIdentity service = new ServiceIdentity();
service.setName("coretech.storage");
setServicePublicKey(service, "0", ZTS_Y64_CERT0);
com.yahoo.athenz.zms.PublicKeyEntry publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT1);
publicKey.setId("1");
List<com.yahoo.athenz.zms.PublicKeyEntry> publicKeys = new ArrayList<com.yahoo.athenz.zms.PublicKeyEntry>();
publicKeys.add(publicKey);
service.setPublicKeys(publicKeys);
List<ServiceIdentity> services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
DomainData domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
/* remove V0 public key */
dataCache = new DataCache();
service = new ServiceIdentity();
service.setName("coretech.storage");
publicKeys = new ArrayList<com.yahoo.athenz.zms.PublicKeyEntry>();
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT1);
publicKey.setId("1");
publicKeys.add(publicKey);
service.setPublicKeys(publicKeys);
services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
assertNull(store.getPublicKey("coretech", "storage", "0"));
assertEquals(store.getPublicKey("coretech", "storage", "1"), ZTS_PEM_CERT1);
assertNull(store.getPublicKey("coretech", "storage", "2"));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddRoleToListMultipleRoleSpecifiedNoMatch.
@Test
public void testAddRoleToListMultipleRoleSpecifiedNoMatch() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
Set<String> accessibleRoles = new HashSet<>();
String[] requestedRoleList = { "admin2", "admin3", "admin4" };
store.addRoleToList("coretech:role.admin", "coretech:role.", requestedRoleList, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 0);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRemovePublicKeysNull.
@Test
public void testRemovePublicKeysNull() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
store.publicKeyCache.put("coretech.storage_0", "PublicKey0");
store.removePublicKeys(null);
assertEquals(store.publicKeyCache.size(), 1);
assertTrue(store.publicKeyCache.containsKey("coretech.storage_0"));
}
Aggregations