use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testProcessTrustedDomainMemberRoleNotValid.
@Test
public void testProcessTrustedDomainMemberRoleNotValid() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = createDataCache("coretech");
Set<String> accessibleRoles = new HashSet<>();
String prefix = "coretech" + ROLE_POSTFIX;
String identity = "user_domain.user1";
String[] requestedRoleList = { "coretech:role.writers" };
/* invalid role causing no match */
Set<String> trustedResources = new HashSet<>();
trustedResources.add("coretech:role.admin");
trustedResources.add("coretech:role.readers");
store.processTrustedDomain(dataCache, identity, prefix, requestedRoleList, trustedResources, accessibleRoles, false);
assertEquals(accessibleRoles.size(), 0);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testRoleMatchInSetExpiration.
@Test
public void testRoleMatchInSetExpiration() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
Set<MemberRole> checkSet = new HashSet<>();
checkSet.add(new MemberRole("expired", System.currentTimeMillis() - 100000));
checkSet.add(new MemberRole("notexpired", System.currentTimeMillis() + 100000));
assertFalse(store.roleMatchInSet("expired", checkSet));
assertTrue(store.roleMatchInSet("notexpired", checkSet));
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class ZTSImplTest method setup.
@BeforeMethod
public void setup() {
// we want to make sure we start we clean dir structure
ZMSFileChangeLogStore.deleteDirectory(new File(ZTS_DATA_STORE_PATH));
String privKeyName = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
File privKeyFile = new File(privKeyName);
String privKey = Crypto.encodedFile(privKeyFile);
privateKey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
/* create our data store */
roleTokenDefaultTimeout = 2400;
System.setProperty(ZTSConsts.ZTS_PROP_ROLE_TOKEN_DEFAULT_TIMEOUT, Integer.toString(roleTokenDefaultTimeout));
roleTokenMaxTimeout = 96000;
System.setProperty(ZTSConsts.ZTS_PROP_ROLE_TOKEN_MAX_TIMEOUT, Integer.toString(roleTokenMaxTimeout));
System.setProperty(ZTSConsts.ZTS_PROP_AUTHORIZED_PROXY_USERS, "user_domain.proxy-user1,user_domain.proxy-user2");
ChangeLogStore structStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", privateKey, "0");
CloudStore cloudStore = new CloudStore(null);
cloudStore.setHttpClient(null);
System.setProperty(ZTSConsts.ZTS_PROP_SELF_SIGNER_PRIVATE_KEY_FNAME, "src/test/resources/private_encrypted.key");
System.setProperty(ZTSConsts.ZTS_PROP_SELF_SIGNER_PRIVATE_KEY_PASSWORD, "athenz");
ZMSFileChangeLogStore.deleteDirectory(new File("/tmp/zts_server_cert_store"));
System.setProperty(ZTSConsts.ZTS_PROP_CERT_FILE_STORE_PATH, "/tmp/zts_server_cert_store");
store = new DataStore(structStore, cloudStore);
zts = new ZTSImpl(cloudStore, store);
ZTSImpl.serverHostName = "localhost";
authorizer = new ZTSAuthorizer(store);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class InstanceProviderManagerTest method setup.
@BeforeMethod
public void setup() {
// we want to make sure we start we clean dir structure
ZMSFileChangeLogStore.deleteDirectory(new File(ZTS_DATA_STORE_PATH));
File privKeyFile = new File(ZTS_PRIVATE_KEY);
String privKey = Crypto.encodedFile(privKeyFile);
privateKey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
ChangeLogStore structStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", privateKey, "0");
System.setProperty(ZTSConsts.ZTS_PROP_PROVIDER_ENDPOINTS, ".athenz2.com,.athenz.com");
store = new DataStore(structStore, null);
}
use of com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheRemovedPublicKeysVersions.
@Test
public void testAddDomainToCacheRemovedPublicKeysVersions() {
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);
List<com.yahoo.athenz.zms.PublicKeyEntry> publicKeys = new ArrayList<com.yahoo.athenz.zms.PublicKeyEntry>();
com.yahoo.athenz.zms.PublicKeyEntry publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT1);
publicKey.setId("1");
publicKeys.add(publicKey);
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT2);
publicKey.setId("2");
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);
/* update multiple version public keys */
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_CERT0);
publicKey.setId("0");
publicKeys.add(publicKey);
publicKey = new com.yahoo.athenz.zms.PublicKeyEntry();
publicKey.setKey(ZTS_Y64_CERT2);
publicKey.setId("2");
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);
assertEquals(store.getPublicKey("coretech", "storage", "0"), ZTS_PEM_CERT0);
assertNull(store.getPublicKey("coretech", "storage", "1"));
assertEquals(store.getPublicKey("coretech", "storage", "2"), ZTS_PEM_CERT2);
assertNull(store.getPublicKey("coretech", "storage", "3"));
}
Aggregations