use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class ClientBuilderFactoryTest method testValidate.
@Test
public void testValidate() {
AwsCredentialsProvider mock = mock(AwsCredentialsProvider.class);
when(awsOptions.getAwsCredentialsProvider()).thenReturn(mock);
when(mock.resolveCredentials()).thenReturn(mock(AwsCredentials.class));
// finally success
validate(awsOptions, ClientConfiguration.builder().build());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class ClientBuilderFactoryTest method testCheckConfigurationUsingOptions.
@Test
public void testCheckConfigurationUsingOptions() {
ClientConfiguration config = ClientConfiguration.builder().build();
when(awsOptions.getAwsRegion()).thenReturn(null);
assertThatThrownBy(() -> defaultFactory().checkConfiguration(config, awsOptions)).hasMessage("No AWS region available");
when(awsOptions.getAwsRegion()).thenReturn(EU_WEST_2);
when(awsOptions.getAwsCredentialsProvider()).thenReturn(null);
assertThatThrownBy(() -> defaultFactory().checkConfiguration(config, awsOptions)).hasMessage("No AWS credentials provider available");
AwsCredentialsProvider mock = mock(AwsCredentialsProvider.class);
when(awsOptions.getAwsCredentialsProvider()).thenReturn(mock);
when(mock.resolveCredentials()).thenReturn(mock(AwsCredentials.class));
// finally success
defaultFactory().checkConfiguration(config, awsOptions);
when(mock.resolveCredentials()).thenThrow(new RuntimeException("Error resolving credentials"));
assertThatThrownBy(() -> defaultFactory().checkConfiguration(config, awsOptions)).hasMessage("Error resolving credentials");
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class DynamoDBIOReadTest method testBuildWithCredentialsProviderAndRegion.
@Test
public void testBuildWithCredentialsProviderAndRegion() {
Region region = Region.US_EAST_1;
AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create();
Read<Object> read = DynamoDBIO.read().withDynamoDbClientProvider(credentialsProvider, region.id());
assertThat(read.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, null));
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class BasicSnsAsyncClientProviderTest method testSerialization.
@Test
public void testSerialization() {
AwsCredentialsProvider awsCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create("ACCESS_KEY_ID", "SECRET_ACCESS_KEY"));
BasicSnsAsyncClientProvider snsAsyncClientProvider = new BasicSnsAsyncClientProvider(awsCredentialsProvider, "us-east-1", null);
byte[] serializedBytes = SerializableUtils.serializeToByteArray(snsAsyncClientProvider);
BasicSnsAsyncClientProvider snsAsyncClientProviderDeserialized = (BasicSnsAsyncClientProvider) SerializableUtils.deserializeFromByteArray(serializedBytes, "Aws Credentials Provider");
assertEquals(snsAsyncClientProvider, snsAsyncClientProviderDeserialized);
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project ddf by codice.
the class MetacardS3StorageRoute method getS3Client.
private S3Client getS3Client() {
Region region = Region.of(getS3Region());
if (StringUtils.isNotBlank(s3AccessKey)) {
AwsCredentials awsCredentials = AwsBasicCredentials.create(s3AccessKey, s3SecretKey);
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(awsCredentials);
return S3Client.builder().credentialsProvider(credentialsProvider).endpointOverride(URI.create(s3Endpoint)).region(region).build();
}
return S3Client.builder().endpointOverride(URI.create(s3Endpoint)).region(region).build();
}
Aggregations