Search in sources :

Example 1 with HttpCredentialsProvider

use of software.amazon.awssdk.auth.credentials.HttpCredentialsProvider in project aws-sdk-java-v2 by aws.

the class CrtCredentialProviderAdapterTest method crtCredentials_provideAwsCredentials_shouldInvokeResolveAndClose.

@Test
public void crtCredentials_provideAwsCredentials_shouldInvokeResolveAndClose() {
    HttpCredentialsProvider awsCredentialsProvider = Mockito.mock(HttpCredentialsProvider.class);
    AwsCredentials credentials = new AwsCredentials() {

        @Override
        public String accessKeyId() {
            return "foo";
        }

        @Override
        public String secretAccessKey() {
            return "bar";
        }
    };
    when(awsCredentialsProvider.resolveCredentials()).thenReturn(credentials);
    CrtCredentialsProviderAdapter adapter = new CrtCredentialsProviderAdapter(awsCredentialsProvider);
    CredentialsProvider crtCredentialsProvider = adapter.crtCredentials();
    Credentials crtCredentials = crtCredentialsProvider.getCredentials().join();
    assertThat(crtCredentials.getAccessKeyId()).isEqualTo("foo".getBytes(StandardCharsets.UTF_8));
    assertThat(crtCredentials.getSecretAccessKey()).isEqualTo("bar".getBytes(StandardCharsets.UTF_8));
    verify(awsCredentialsProvider).resolveCredentials();
    adapter.close();
    verify(awsCredentialsProvider).close();
}
Also used : AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) HttpCredentialsProvider(software.amazon.awssdk.auth.credentials.HttpCredentialsProvider) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) HttpCredentialsProvider(software.amazon.awssdk.auth.credentials.HttpCredentialsProvider) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) CredentialsProvider(software.amazon.awssdk.crt.auth.credentials.CredentialsProvider) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) Credentials(software.amazon.awssdk.crt.auth.credentials.Credentials) AwsSessionCredentials(software.amazon.awssdk.auth.credentials.AwsSessionCredentials) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)1 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)1 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)1 AwsSessionCredentials (software.amazon.awssdk.auth.credentials.AwsSessionCredentials)1 HttpCredentialsProvider (software.amazon.awssdk.auth.credentials.HttpCredentialsProvider)1 StaticCredentialsProvider (software.amazon.awssdk.auth.credentials.StaticCredentialsProvider)1 Credentials (software.amazon.awssdk.crt.auth.credentials.Credentials)1 CredentialsProvider (software.amazon.awssdk.crt.auth.credentials.CredentialsProvider)1