Search in sources :

Example 1 with CertRecordStore

use of com.yahoo.athenz.common.server.cert.CertRecordStore in project athenz by yahoo.

the class AWSCertRecordStoreFactoryTest method testCreate.

@Test
public void testCreate() {
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE, "instance");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER, "rds-user");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE, "role");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME, "1");
    AWSCertRecordStoreFactory factory = new TestAWSCertRecordStoreFactory();
    CertRecordStore store = factory.create(null);
    // sleep a couple of seconds for the updater to run
    try {
        Thread.sleep(2000);
    } catch (InterruptedException ignored) {
    }
    assertNotNull(store);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME);
}
Also used : CertRecordStore(com.yahoo.athenz.common.server.cert.CertRecordStore) Test(org.testng.annotations.Test)

Example 2 with CertRecordStore

use of com.yahoo.athenz.common.server.cert.CertRecordStore in project athenz by yahoo.

the class AWSCertRecordStoreFactoryTest method testGetTokenException.

@Test
public void testGetTokenException() {
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE, "instance");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER, "rds-user");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE, "role");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME, "1");
    AWSCertRecordStoreFactory factory = new TestAWSCertRecordStoreFactory2();
    CertRecordStore store = factory.create(null);
    assertNotNull(store);
    ((TestAWSCertRecordStoreFactory2) factory).setThrowGetTokenExc(true);
    // we should not get any exceptions even though the get token
    // call will throw exceptions
    AWSCertRecordStoreFactory.CredentialsUpdater updater = factory.new CredentialsUpdater();
    updater.run();
    updater.run();
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME);
}
Also used : CertRecordStore(com.yahoo.athenz.common.server.cert.CertRecordStore) Test(org.testng.annotations.Test)

Example 3 with CertRecordStore

use of com.yahoo.athenz.common.server.cert.CertRecordStore in project athenz by yahoo.

the class AWSCertRecordStoreFactoryTest method testCredentialsUpdater.

@Test
public void testCredentialsUpdater() {
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE, "instance");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER, "rds-user2");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE, "role");
    System.setProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME, "1");
    AWSCertRecordStoreFactory factory = new TestAWSCertRecordStoreFactory();
    CertRecordStore store = factory.create(null);
    assertNotNull(store);
    // sleep a couple of seconds for the updater to run
    try {
        Thread.sleep(2000);
    } catch (InterruptedException ignored) {
    }
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE);
    System.clearProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME);
}
Also used : CertRecordStore(com.yahoo.athenz.common.server.cert.CertRecordStore) Test(org.testng.annotations.Test)

Example 4 with CertRecordStore

use of com.yahoo.athenz.common.server.cert.CertRecordStore in project athenz by yahoo.

the class DynamoDBCertRecordStoreFactoryTest method testCreate.

@Test
public void testCreate() {
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_TABLE_NAME, "Athenz-ZTS-Table");
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_INDEX_CURRENT_TIME_NAME, "Athenz-ZTS-Current-Time-Index");
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_INDEX_HOST_NAME, "Athenz-ZTS-Host-Name-Index");
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    TestDynamoDBCertRecordStoreFactory factory = new TestDynamoDBCertRecordStoreFactory();
    CertRecordStore store = factory.create(keyStore);
    assertNotNull(store);
    System.clearProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_TABLE_NAME);
    System.clearProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_INDEX_CURRENT_TIME_NAME);
    System.clearProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_INDEX_HOST_NAME);
}
Also used : CertRecordStore(com.yahoo.athenz.common.server.cert.CertRecordStore) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 5 with CertRecordStore

use of com.yahoo.athenz.common.server.cert.CertRecordStore in project athenz by yahoo.

the class JDBCCertRecordStoreFactoryTest method testCreate.

@Test
public void testCreate() {
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_STORE, "jdbc:mysql://localhost");
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_USER, "user");
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_PASSWORD, "password");
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password");
    JDBCCertRecordStoreFactory factory = new JDBCCertRecordStoreFactory();
    CertRecordStore store = factory.create(keyStore);
    assertNotNull(store);
}
Also used : CertRecordStore(com.yahoo.athenz.common.server.cert.CertRecordStore) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Aggregations

CertRecordStore (com.yahoo.athenz.common.server.cert.CertRecordStore)5 Test (org.testng.annotations.Test)5 PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)2