Search in sources :

Example 11 with AwsCredentialsProvider

use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.

the class AwsModuleTest method testStaticCredentialsProviderSerializationDeserialization.

@Test
public void testStaticCredentialsProviderSerializationDeserialization() throws Exception {
    AwsCredentialsProvider provider = StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"));
    assertThat(serializeAndDeserialize(provider)).hasSameClassAs(provider).isEqualToComparingFieldByFieldRecursively(provider);
    provider = StaticCredentialsProvider.create(AwsSessionCredentials.create("key", "secret", "token"));
    assertThat(serializeAndDeserialize(provider)).hasSameClassAs(provider).isEqualToComparingFieldByFieldRecursively(provider);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Test(org.junit.Test)

Example 12 with AwsCredentialsProvider

use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.

the class AwsSerializableUtilsTest method testAwsCredentialsProviderSerialization.

@Test
public void testAwsCredentialsProviderSerialization() {
    AwsCredentialsProvider awsCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
    String awsCredentialsProviderSerialized = AwsSerializableUtils.serializeAwsCredentialsProvider(awsCredentialsProvider);
    AwsCredentialsProvider awsCredentialsProviderDeserialized = AwsSerializableUtils.deserializeAwsCredentialsProvider(awsCredentialsProviderSerialized);
    assertTrue(awsCredentialsProviderDeserialized instanceof StaticCredentialsProvider);
    AwsCredentials awsCredentials = awsCredentialsProviderDeserialized.resolveCredentials();
    assertEquals(ACCESS_KEY_ID, awsCredentials.accessKeyId());
    assertEquals(SECRET_ACCESS_KEY, awsCredentials.secretAccessKey());
}
Also used : StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Test(org.junit.Test)

Example 13 with AwsCredentialsProvider

use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.

the class AwsOptionsTest method testSetAwsCredentialsProvider.

@Test
public void testSetAwsCredentialsProvider() {
    AwsOptions options = create("--awsCredentialsProvider={\"@type\":\"StaticCredentialsProvider\",\"accessKeyId\":\"key\",\"secretAccessKey\":\"secret\"}");
    AwsCredentialsProvider expected = StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"));
    assertThat(options.getAwsCredentialsProvider()).isEqualToComparingFieldByFieldRecursively(expected);
    assertThat(serializeDeserialize(options).getAwsCredentialsProvider()).isEqualToComparingFieldByFieldRecursively(expected);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Test(org.junit.Test)

Example 14 with AwsCredentialsProvider

use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.

the class SnsIOTest method testBuildWithCredentialsProviderAndRegion.

@Test
public void testBuildWithCredentialsProviderAndRegion() {
    Region region = Region.US_EAST_1;
    AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create();
    Write<Object> write = SnsIO.write().withSnsClientProvider(credentialsProvider, region.id());
    assertThat(write.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, null));
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Region(software.amazon.awssdk.regions.Region) Test(org.junit.Test)

Example 15 with AwsCredentialsProvider

use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.

the class SqsIOReadTest method testBuildWithCredentialsProviderAndRegionAndEndpoint.

@Test
public void testBuildWithCredentialsProviderAndRegionAndEndpoint() {
    Region region = Region.US_EAST_1;
    AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create();
    URI endpoint = URI.create("localhost:9999");
    Read read = SqsIO.read().withSqsClientProvider(credentialsProvider, region.id(), endpoint);
    assertThat(read.clientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, endpoint));
}
Also used : Read(org.apache.beam.sdk.io.aws2.sqs.SqsIO.Read) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Region(software.amazon.awssdk.regions.Region) URI(java.net.URI) Test(org.junit.Test)

Aggregations

AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)40 Test (org.junit.Test)39 Region (software.amazon.awssdk.regions.Region)14 Properties (java.util.Properties)8 URI (java.net.URI)6 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)6 GlueSchemaRegistryDeserializationFacade (com.amazonaws.services.schemaregistry.deserializers.GlueSchemaRegistryDeserializationFacade)4 HashMap (java.util.HashMap)2 Read (org.apache.beam.sdk.io.aws2.kinesis.KinesisIO.Read)2 Read (org.apache.beam.sdk.io.aws2.sqs.SqsIO.Read)2 Write (org.apache.beam.sdk.io.aws2.sqs.SqsIO.Write)2 DefaultCredentialsProvider (software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider)2 ProfileCredentialsProvider (software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider)2 StaticCredentialsProvider (software.amazon.awssdk.auth.credentials.StaticCredentialsProvider)2 Supplier (java.util.function.Supplier)1 SerializableUtils.deserializeFromByteArray (org.apache.beam.sdk.util.SerializableUtils.deserializeFromByteArray)1 SerializableUtils.serializeToByteArray (org.apache.beam.sdk.util.SerializableUtils.serializeToByteArray)1 ThrowingSupplier (org.apache.beam.sdk.util.ThrowingSupplier)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)1