Search in sources :

Example 1 with ProfileCredentialsProvider

use of software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider 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 2 with ProfileCredentialsProvider

use of software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider 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)

Aggregations

Properties (java.util.Properties)2 Test (org.junit.Test)2 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)2 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)2 ProfileCredentialsProvider (software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider)2