Search in sources :

Example 1 with PrivateKeyStore

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);
}
Also used : ObjectStore(com.yahoo.athenz.zms.store.ObjectStore) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 2 with PrivateKeyStore

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);
}
Also used : ObjectStore(com.yahoo.athenz.zms.store.ObjectStore) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 3 with PrivateKeyStore

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);
    }
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 4 with PrivateKeyStore

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);
    }
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) ServerPrivateKey(com.yahoo.athenz.auth.ServerPrivateKey) Test(org.testng.annotations.Test)

Example 5 with PrivateKeyStore

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);
    }
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) ServerPrivateKey(com.yahoo.athenz.auth.ServerPrivateKey) Test(org.testng.annotations.Test)

Aggregations

PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)36 Test (org.testng.annotations.Test)35 ResourceException (com.yahoo.athenz.zts.ResourceException)8 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)6 ServerPrivateKey (com.yahoo.athenz.auth.ServerPrivateKey)3 WorkloadRecordStore (com.yahoo.athenz.common.server.workload.WorkloadRecordStore)3 ZTSClientNotificationSender (com.yahoo.athenz.zts.ZTSClientNotificationSender)3 ZTSClientNotificationSenderImpl (com.yahoo.athenz.zts.notification.ZTSClientNotificationSenderImpl)3 CertRecordStore (com.yahoo.athenz.common.server.cert.CertRecordStore)2 SSHRecordStore (com.yahoo.athenz.common.server.ssh.SSHRecordStore)2 ObjectStore (com.yahoo.athenz.zms.store.ObjectStore)2 FilePrivateKeyStore (com.yahoo.athenz.auth.impl.FilePrivateKeyStore)1 ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 KeyStore (java.security.KeyStore)1 PrivateKey (java.security.PrivateKey)1 SecureRandom (java.security.SecureRandom)1 KeyManager (javax.net.ssl.KeyManager)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1