Search in sources :

Example 1 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderSystemProperties.

@Test
public void testGetCredentialsProviderSystemProperties() {
    Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "SYS_PROP");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
    assertTrue(credentialsProvider instanceof SystemPropertyCredentialsProvider);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Properties(java.util.Properties) SystemPropertyCredentialsProvider(software.amazon.awssdk.auth.credentials.SystemPropertyCredentialsProvider) Test(org.junit.Test)

Example 2 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderNamedProfile.

@Test
public void testGetCredentialsProviderNamedProfile() {
    Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "PROFILE");
    properties.setProperty(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "foo");
    properties.setProperty(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
    assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
    AwsCredentials credentials = credentialsProvider.resolveCredentials();
    assertEquals("22222222222222222222", credentials.accessKeyId());
    assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY2222222222", credentials.secretAccessKey());
}
Also used : AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) ProfileCredentialsProvider(software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderEnvironmentVariables.

@Test
public void testGetCredentialsProviderEnvironmentVariables() {
    Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "ENV_VAR");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
    assertTrue(credentialsProvider instanceof EnvironmentVariableCredentialsProvider);
}
Also used : EnvironmentVariableCredentialsProvider(software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderProfile.

@Test
public void testGetCredentialsProviderProfile() {
    Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "PROFILE");
    properties.put(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "default");
    properties.put(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
    assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
    AwsCredentials credentials = credentialsProvider.resolveCredentials();
    assertEquals("11111111111111111111", credentials.accessKeyId());
    assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY1111111111", credentials.secretAccessKey());
}
Also used : AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) ProfileCredentialsProvider(software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with AwsCredentialsProvider

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

the class GlueSchemaRegistryInputStreamDeserializerTest method testAwsCredentialsProviderFromConfig.

@Test
public void testAwsCredentialsProviderFromConfig() throws Exception {
    Map<String, Object> config = new HashMap<>(configs);
    config.put(AWS_ACCESS_KEY_ID, "ak");
    config.put(AWS_SECRET_ACCESS_KEY, "sk");
    GlueSchemaRegistryInputStreamDeserializer glueSchemaRegistryInputStreamDeserializer = new GlueSchemaRegistryInputStreamDeserializer(config);
    GlueSchemaRegistryDeserializationFacade facade = getField("glueSchemaRegistryDeserializationFacade", glueSchemaRegistryInputStreamDeserializer);
    AwsCredentialsProvider credentialsProvider = facade.getCredentialsProvider();
    assertThat(credentialsProvider.resolveCredentials().accessKeyId()).isEqualTo("ak");
    assertThat(credentialsProvider.resolveCredentials().secretAccessKey()).isEqualTo("sk");
}
Also used : HashMap(java.util.HashMap) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) GlueSchemaRegistryDeserializationFacade(com.amazonaws.services.schemaregistry.deserializers.GlueSchemaRegistryDeserializationFacade) 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