Search in sources :

Example 1 with ZTSClientNotificationSender

use of com.yahoo.athenz.zts.ZTSClientNotificationSender in project athenz by yahoo.

the class DynamoDBClientFetcherImplTest method testGetAuthenticatedClient.

@Test
public void testGetAuthenticatedClient() {
    // public
    String certPath = Resources.getResource("gdpr.aws.core.cert.pem").getPath();
    // private
    String keyPath = Resources.getResource("unit_test_gdpr.aws.core.key.pem").getPath();
    System.setProperty(ZTS_PROP_DYNAMODB_KEY_PATH, keyPath);
    System.setProperty(ZTS_PROP_DYNAMODB_CERT_PATH, certPath);
    System.setProperty(ZTS_PROP_DYNAMODB_DOMAIN, "test.domain");
    System.setProperty(ZTS_PROP_DYNAMODB_REGION, "test.region");
    System.setProperty(ZTS_PROP_DYNAMODB_ROLE, "test.role");
    System.setProperty(ZTS_PROP_DYNAMODB_TRUSTSTORE, "test.truststore");
    System.setProperty(ZTS_PROP_DYNAMODB_TRUSTSTORE_PASSWORD, "test.truststore.password");
    System.setProperty(ZTS_PROP_DYNAMODB_ZTS_URL, "https://dev.zts.athenzcompany.com:4443/zts/v1");
    DynamoDBClientFetcherImpl dynamoDBClientFetcher = new DynamoDBClientFetcherImpl();
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    when(keyStore.getApplicationSecret(Mockito.eq(""), Mockito.eq("test.truststore.password"))).thenReturn("mockPassword");
    ZTSClientNotificationSender ztsClientNotificationSender = Mockito.mock(ZTSClientNotificationSender.class);
    AmazonDynamoDB dynamoDBClient = dynamoDBClientFetcher.getDynamoDBClient(ztsClientNotificationSender, keyStore).getAmazonDynamoDB();
    assertNotNull(dynamoDBClient);
    // Also try with min and max expiry set
    System.setProperty(ZTS_PROP_DYNAMODB_MIN_EXPIRY_TIME, "10");
    System.setProperty(ZTS_PROP_DYNAMODB_MAX_EXPIRY_TIME, "100");
    dynamoDBClient = dynamoDBClientFetcher.getDynamoDBClient(ztsClientNotificationSender, keyStore).getAmazonDynamoDB();
    assertNotNull(dynamoDBClient);
    System.clearProperty(ZTS_PROP_DYNAMODB_KEY_PATH);
    System.clearProperty(ZTS_PROP_DYNAMODB_CERT_PATH);
    System.clearProperty(ZTS_PROP_DYNAMODB_DOMAIN);
    System.clearProperty(ZTS_PROP_DYNAMODB_REGION);
    System.clearProperty(ZTS_PROP_DYNAMODB_ROLE);
    System.clearProperty(ZTS_PROP_DYNAMODB_TRUSTSTORE);
    System.clearProperty(ZTS_PROP_DYNAMODB_TRUSTSTORE_PASSWORD);
    System.clearProperty(ZTS_PROP_DYNAMODB_ZTS_URL);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) ZTSClientNotificationSender(com.yahoo.athenz.zts.ZTSClientNotificationSender) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) Test(org.testng.annotations.Test)

Example 2 with ZTSClientNotificationSender

use of com.yahoo.athenz.zts.ZTSClientNotificationSender in project athenz by yahoo.

the class DynamoDBClientFetcherImplTest method testGetClientWithDefaultRegion.

@Test
public void testGetClientWithDefaultRegion() {
    DynamoDBClientFetcher dynamoDBClientFetcher = new DynamoDBClientFetcherImpl("testRegion");
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    ZTSClientNotificationSender ztsClientNotificationSender = Mockito.mock(ZTSClientNotificationSender.class);
    AmazonDynamoDB dynamoDBClient = dynamoDBClientFetcher.getDynamoDBClient(ztsClientNotificationSender, keyStore).getAmazonDynamoDB();
    assertNotNull(dynamoDBClient);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) ZTSClientNotificationSender(com.yahoo.athenz.zts.ZTSClientNotificationSender) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) Test(org.testng.annotations.Test)

Example 3 with ZTSClientNotificationSender

use of com.yahoo.athenz.zts.ZTSClientNotificationSender in project athenz by yahoo.

the class DynamoDBClientFetcherImplTest method testGetClientWitSpecifiedRegion.

@Test
public void testGetClientWitSpecifiedRegion() {
    System.setProperty(ZTS_PROP_DYNAMODB_REGION, "test.region");
    DynamoDBClientFetcher dynamoDBClientFetcher = DynamoDBClientFetcherFactory.getDynamoDBClientFetcher();
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    ZTSClientNotificationSender ztsClientNotificationSender = Mockito.mock(ZTSClientNotificationSender.class);
    AmazonDynamoDB dynamoDBClient = dynamoDBClientFetcher.getDynamoDBClient(ztsClientNotificationSender, keyStore).getAmazonDynamoDB();
    assertNotNull(dynamoDBClient);
    System.clearProperty(ZTS_PROP_DYNAMODB_REGION);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) ZTSClientNotificationSender(com.yahoo.athenz.zts.ZTSClientNotificationSender) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) Test(org.testng.annotations.Test)

Aggregations

AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)3 PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)3 ZTSClientNotificationSender (com.yahoo.athenz.zts.ZTSClientNotificationSender)3 Test (org.testng.annotations.Test)3