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);
}
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);
}
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);
}
Aggregations