Search in sources :

Example 1 with DefaultCredentialsProvider

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

the class AWSAsyncSinkUtilTest method testCreateKinesisAsyncClient.

@Test
public void testCreateKinesisAsyncClient() {
    Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
    MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
    ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().build();
    SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().build();
    AWSAsyncSinkUtil.createAwsAsyncClient(properties, builder, httpClient, clientOverrideConfiguration);
    verify(builder).overrideConfiguration(clientOverrideConfiguration);
    verify(builder).httpClient(httpClient);
    verify(builder).region(Region.of("eu-west-2"));
    verify(builder).credentialsProvider(argThat(cp -> cp instanceof DefaultCredentialsProvider));
    verify(builder, never()).endpointOverride(any());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) AwsAsyncClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) SdkAdvancedClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) Duration(java.time.Duration) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) URI(java.net.URI) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Region(software.amazon.awssdk.regions.Region) ClientAsyncConfiguration(software.amazon.awssdk.core.client.config.ClientAsyncConfiguration) Properties(java.util.Properties) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) Mockito.verify(org.mockito.Mockito.verify) AWS_REGION(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_REGION) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) Mockito.never(org.mockito.Mockito.never) SdkClient(software.amazon.awssdk.core.SdkClient) AWS_ENDPOINT(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_ENDPOINT) AWSAsyncSinkUtil.formatFlinkUserAgentPrefix(org.apache.flink.connector.aws.util.AWSAsyncSinkUtil.formatFlinkUserAgentPrefix) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) Mockito.mock(org.mockito.Mockito.mock) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with DefaultCredentialsProvider

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

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

Test (org.junit.Test)3 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)3 DefaultCredentialsProvider (software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider)3 Properties (java.util.Properties)2 URI (java.net.URI)1 Duration (java.time.Duration)1 AWS_ENDPOINT (org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_ENDPOINT)1 AWS_REGION (org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_REGION)1 AWSAsyncSinkUtil.formatFlinkUserAgentPrefix (org.apache.flink.connector.aws.util.AWSAsyncSinkUtil.formatFlinkUserAgentPrefix)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.never (org.mockito.Mockito.never)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 AwsAsyncClientBuilder (software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder)1 AwsClientBuilder (software.amazon.awssdk.awscore.client.builder.AwsClientBuilder)1 SdkClient (software.amazon.awssdk.core.SdkClient)1 ClientAsyncConfiguration (software.amazon.awssdk.core.client.config.ClientAsyncConfiguration)1 ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)1