Search in sources :

Example 36 with AwsCredentialsProvider

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

the class GlueSchemaRegistryJsonSchemaCoderTest method testAwsCredentialsProviderFromConfig.

@Test
public void testAwsCredentialsProviderFromConfig() throws Exception {
    Map<String, Object> config = new HashMap<>(getBaseConfig());
    config.put(AWS_ACCESS_KEY_ID, "ak");
    config.put(AWS_SECRET_ACCESS_KEY, "sk");
    GlueSchemaRegistryJsonSchemaCoder coder = new GlueSchemaRegistryJsonSchemaCoder("test", config);
    GlueSchemaRegistryDeserializationFacade facade = getField("glueSchemaRegistryDeserializationFacade", coder);
    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)

Example 37 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderAuto.

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

Example 38 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderAssumeRole.

@Test
public void testGetCredentialsProviderAssumeRole() {
    Properties properties = spy(TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "ASSUME_ROLE"));
    properties.setProperty(AWS_REGION, "eu-west-2");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
    assertTrue(credentialsProvider instanceof StsAssumeRoleCredentialsProvider);
    verify(properties).getProperty(AWSConfigConstants.roleArn(AWS_CREDENTIALS_PROVIDER));
    verify(properties).getProperty(AWSConfigConstants.roleSessionName(AWS_CREDENTIALS_PROVIDER));
    verify(properties).getProperty(AWSConfigConstants.externalId(AWS_CREDENTIALS_PROVIDER));
    verify(properties).getProperty(AWS_REGION);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) StsAssumeRoleCredentialsProvider(software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider) Properties(java.util.Properties) Test(org.junit.Test)

Example 39 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderWebIdentityTokenFileCredentialsProvider.

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

Example 40 with AwsCredentialsProvider

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

the class AWSGeneralUtilTest method testGetCredentialsProviderFromMap.

@Test
public void testGetCredentialsProviderFromMap() {
    Map<String, Object> config = ImmutableMap.of(AWS_CREDENTIALS_PROVIDER, "AUTO");
    AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(config);
    assertTrue(credentialsProvider instanceof DefaultCredentialsProvider);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) 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