Search in sources :

Example 1 with StsAssumeRoleCredentialsProvider

use of software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider in project iep by Netflix.

the class AwsClientFactoryTest method createCredentialsProviderOverride.

@Test
public void createCredentialsProviderOverride() throws Exception {
    AwsClientFactory factory = new AwsClientFactory(config);
    AwsCredentialsProvider creds = factory.createCredentialsProvider("ec2-test");
    Assert.assertTrue(creds instanceof StsAssumeRoleCredentialsProvider);
    Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getRequest(creds).roleArn());
    Assert.assertEquals("iep", getRequest(creds).roleSessionName());
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.core.auth.AwsCredentialsProvider) StsAssumeRoleCredentialsProvider(software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider) Test(org.junit.Test)

Example 2 with StsAssumeRoleCredentialsProvider

use of software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider 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)

Aggregations

Test (org.junit.Test)2 StsAssumeRoleCredentialsProvider (software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider)2 Properties (java.util.Properties)1 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)1 AwsCredentialsProvider (software.amazon.awssdk.core.auth.AwsCredentialsProvider)1