Search in sources :

Example 1 with STSAssumeRoleSessionCredentialsProvider

use of com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider 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", null);
    Assert.assertTrue(creds instanceof STSAssumeRoleSessionCredentialsProvider);
    Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getField(creds, "roleArn"));
    Assert.assertEquals("iep", getField(creds, "roleSessionName"));
}
Also used : STSAssumeRoleSessionCredentialsProvider(com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 2 with STSAssumeRoleSessionCredentialsProvider

use of com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider in project iep by Netflix.

the class AwsClientFactoryTest method createCredentialsProviderForAccount.

@Test
public void createCredentialsProviderForAccount() throws Exception {
    AwsClientFactory factory = new AwsClientFactory(config);
    AWSCredentialsProvider creds = factory.createCredentialsProvider("ec2-account", "123");
    Assert.assertTrue(creds instanceof STSAssumeRoleSessionCredentialsProvider);
    Assert.assertEquals("arn:aws:iam::123:role/IepTest", getField(creds, "roleArn"));
    Assert.assertEquals("iep", getField(creds, "roleSessionName"));
}
Also used : STSAssumeRoleSessionCredentialsProvider(com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 3 with STSAssumeRoleSessionCredentialsProvider

use of com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider in project iep by Netflix.

the class AwsClientFactoryTest method createCredentialsProviderForAccountIgnored.

@Test
public void createCredentialsProviderForAccountIgnored() throws Exception {
    AwsClientFactory factory = new AwsClientFactory(config);
    AWSCredentialsProvider creds = factory.createCredentialsProvider("ec2-test", "123");
    Assert.assertTrue(creds instanceof STSAssumeRoleSessionCredentialsProvider);
    Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getField(creds, "roleArn"));
    Assert.assertEquals("iep", getField(creds, "roleSessionName"));
}
Also used : STSAssumeRoleSessionCredentialsProvider(com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 4 with STSAssumeRoleSessionCredentialsProvider

use of com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider in project beam by apache.

the class AwsModuleTest method testSTSAssumeRoleSessionCredentialsProviderSerializationDeserialization.

@Test
public void testSTSAssumeRoleSessionCredentialsProviderSerializationDeserialization() throws Exception {
    String roleArn = "arn:aws:iam::000111222333:role/TestRole";
    String roleSessionName = "roleSessionName";
    STSAssumeRoleSessionCredentialsProvider credentialsProvider = new STSAssumeRoleSessionCredentialsProvider.Builder(roleArn, roleSessionName).build();
    String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
    AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(roleArn, readField(deserializedCredentialsProvider, "roleArn", true));
    assertEquals(roleSessionName, readField(deserializedCredentialsProvider, "roleSessionName", true));
}
Also used : STSAssumeRoleSessionCredentialsProvider(com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Aggregations

AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)4 STSAssumeRoleSessionCredentialsProvider (com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider)4 Test (org.junit.Test)4