use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.
the class JDBCObjectStoreFactoryTest method testCreateWriteOnly.
@Test
public void testCreateWriteOnly() {
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_STORE, "jdbc:mysql://localhost");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_USER, "user");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_PASSWORD, "password");
System.clearProperty(ZMSConsts.ZMS_PROP_JDBC_RO_STORE);
System.clearProperty(ZMSConsts.ZMS_PROP_JDBC_RO_USER);
System.clearProperty(ZMSConsts.ZMS_PROP_JDBC_RO_PASSWORD);
PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password");
JDBCObjectStoreFactory factory = new JDBCObjectStoreFactory();
ObjectStore store = factory.create(keyStore);
assertNotNull(store);
}
use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.
the class JDBCObjectStoreFactoryTest method testCreateReadWrite.
@Test
public void testCreateReadWrite() {
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_STORE, "jdbc:mysql://localhost");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_USER, "user");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RW_PASSWORD, "password");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RO_STORE, "jdbc:mysql://localhost");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RO_USER, "user");
System.setProperty(ZMSConsts.ZMS_PROP_JDBC_RO_PASSWORD, "password");
PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password");
JDBCObjectStoreFactory factory = new JDBCObjectStoreFactory();
ObjectStore store = factory.create(keyStore);
assertNotNull(store);
}
use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.
the class FilePrivateKeyStoreTest method testRetrieveAlgoPrivateKeyInalid.
@Test
public void testRetrieveAlgoPrivateKeyInalid() {
FilePrivateKeyStoreFactory factory = new FilePrivateKeyStoreFactory();
PrivateKeyStore store = factory.create();
String saveProp = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY);
assertNull(store.getPrivateKey("app", "localhost", "us-east-1", "ec"));
assertNull(store.getPrivateKey("zms", "localhost", "us-east-1", "unknown"));
System.clearProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY);
assertNull(store.getPrivateKey("zms", "localhost", "us-east-1", "ec"));
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY, "src/test/resources/ec_public_invalid.key");
assertNull(store.getPrivateKey("zms", "localhost", "us-east-1", "ec"));
if (saveProp == null) {
System.clearProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY);
} else {
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY, saveProp);
}
}
use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.
the class FilePrivateKeyStoreTest method testRetrieveRSAPrivateKeyValid.
@Test
public void testRetrieveRSAPrivateKeyValid() {
FilePrivateKeyStoreFactory factory = new FilePrivateKeyStoreFactory();
PrivateKeyStore store = factory.create();
String saveProp = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_RSA_KEY);
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_RSA_KEY, "src/test/resources/unit_test_zts_private_k0.key");
ServerPrivateKey privKey = store.getPrivateKey("zms", "localhost", "us-east-1", "rsa");
assertNotNull(privKey);
if (saveProp == null) {
System.clearProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_RSA_KEY);
} else {
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_RSA_KEY, saveProp);
}
}
use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.
the class FilePrivateKeyStoreTest method testRetrieveECPrivateKeyValid.
@Test
public void testRetrieveECPrivateKeyValid() {
FilePrivateKeyStoreFactory factory = new FilePrivateKeyStoreFactory();
PrivateKeyStore store = factory.create();
String saveProp = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY);
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY, "src/test/resources/unit_test_ec_private.key");
ServerPrivateKey privKey = store.getPrivateKey("zms", "localhost", "us-east-1", "ec");
assertNotNull(privKey);
if (saveProp == null) {
System.clearProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY);
} else {
System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_EC_KEY, saveProp);
}
}
Aggregations