use of software.amazon.awssdk.auth.credentials.AwsBasicCredentials in project beam by apache.
the class ClientBuilderFactoryTest method testCheckConfigurationUsingConfig.
@Test
public void testCheckConfigurationUsingConfig() {
when(awsOptions.getAwsRegion()).thenReturn(null);
when(awsOptions.getAwsCredentialsProvider()).thenReturn(null);
ClientConfiguration noRegion = ClientConfiguration.builder().build();
assertThatThrownBy(() -> defaultFactory().checkConfiguration(noRegion, awsOptions)).hasMessage("No AWS region available");
ClientConfiguration noCredentials = ClientConfiguration.builder().region(US_WEST_1).build();
assertThatThrownBy(() -> defaultFactory().checkConfiguration(noCredentials, awsOptions)).hasMessage("No AWS credentials provider available");
AwsBasicCredentials credentials = AwsBasicCredentials.create("key", "secret");
ClientConfiguration valid = ClientConfiguration.builder().region(US_WEST_1).credentialsProvider(StaticCredentialsProvider.create(credentials)).build();
// finally success
defaultFactory().checkConfiguration(valid, awsOptions);
// awsOptions may be null
defaultFactory().checkConfiguration(valid, null);
}
use of software.amazon.awssdk.auth.credentials.AwsBasicCredentials in project cas by apereo.
the class ChainingAWSCredentialsProviderTests method verifyInstance.
@Test
public void verifyInstance() throws Exception {
val path = File.createTempFile("props", ".txt").getCanonicalPath();
val p = (AwsCredentialsProviderChain) ChainingAWSCredentialsProvider.getInstance("accesskey", "secretKey", "profilePath", path);
val credentials = p.resolveCredentials();
assertNotNull(credentials);
assertTrue(credentials instanceof AwsBasicCredentials);
assertNotNull(ChainingAWSCredentialsProvider.getInstance());
}
use of software.amazon.awssdk.auth.credentials.AwsBasicCredentials in project beam by apache.
the class KinesisIOReadTest method testBuildWithBasicCredentials.
@Test
public void testBuildWithBasicCredentials() {
Region region = Region.US_EAST_1;
AwsBasicCredentials credentials = AwsBasicCredentials.create(KEY, SECRET);
StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);
Read read = KinesisIO.read().withAWSClientsProvider(KEY, SECRET, region);
assertThat(read.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, null));
}
use of software.amazon.awssdk.auth.credentials.AwsBasicCredentials in project beam by apache.
the class KinesisIOReadTest method testBuildWithBasicCredentialsAndCustomEndpoint.
@Test
public void testBuildWithBasicCredentialsAndCustomEndpoint() {
String customEndpoint = "localhost:9999";
Region region = Region.US_WEST_1;
AwsBasicCredentials credentials = AwsBasicCredentials.create("key", "secret");
StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);
Read read = KinesisIO.read().withAWSClientsProvider(KEY, SECRET, region, customEndpoint);
assertThat(read.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, URI.create(customEndpoint)));
}
use of software.amazon.awssdk.auth.credentials.AwsBasicCredentials in project fluency by komamitsu.
the class AwsS3Sender method buildClient.
@VisibleForTesting
protected S3Client buildClient(S3ClientBuilder s3ClientBuilder) {
if (config.getEndpoint() != null) {
try {
URI uri = new URI(config.getEndpoint());
s3ClientBuilder.endpointOverride(uri);
} catch (URISyntaxException e) {
throw new NonRetryableException(String.format("Invalid endpoint. %s", config.getEndpoint()), e);
}
}
if (config.getRegion() != null) {
s3ClientBuilder.region(Region.of(config.getRegion()));
}
if (config.getAwsAccessKeyId() != null && config.getAwsSecretAccessKey() != null) {
AwsBasicCredentials credentials = AwsBasicCredentials.create(config.getAwsAccessKeyId(), config.getAwsSecretAccessKey());
s3ClientBuilder.credentialsProvider(StaticCredentialsProvider.create(credentials));
}
return s3ClientBuilder.build();
}
Aggregations