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();
}
Aggregations