Search in sources :

Example 51 with AWSCredentialsProvider

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

the class AwsSerializableUtilsTest method testFailOnAWSCredentialsProviderSerialization.

@Test(expected = IllegalArgumentException.class)
public void testFailOnAWSCredentialsProviderSerialization() {
    AWSCredentialsProvider credentialsProvider = new UnknownAwsCredentialsProvider();
    serialize(credentialsProvider);
}
Also used : AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 52 with AWSCredentialsProvider

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

the class AwsSerializableUtilsTest method testDefaultAWSCredentialsProviderChainSerialization.

@Test
public void testDefaultAWSCredentialsProviderChainSerialization() {
    AWSCredentialsProvider credentialsProvider = DefaultAWSCredentialsProviderChain.getInstance();
    String expectedSerializedProvider = "{\"@type\":\"DefaultAWSCredentialsProviderChain\"}";
    String serializedProvider = serialize(credentialsProvider);
    assertEquals(expectedSerializedProvider, serializedProvider);
    assertEquals(expectedSerializedProvider, serialize(deserialize(serializedProvider)));
}
Also used : AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 53 with AWSCredentialsProvider

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

the class AwsSerializableUtilsTest method testPropertiesFileCredentialsProviderSerialization.

@Test
public void testPropertiesFileCredentialsProviderSerialization() {
    AWSCredentialsProvider credentialsProvider = new PropertiesFileCredentialsProvider("AwsCredentials.properties");
    String expectedSerializedProvider = "{\"@type\":\"PropertiesFileCredentialsProvider\",\"credentialsFilePath\":\"AwsCredentials.properties\"}";
    String serializedProvider = serialize(credentialsProvider);
    assertEquals(expectedSerializedProvider, serializedProvider);
    assertEquals(expectedSerializedProvider, serialize(deserialize(serializedProvider)));
}
Also used : ClasspathPropertiesFileCredentialsProvider(com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider) PropertiesFileCredentialsProvider(com.amazonaws.auth.PropertiesFileCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 54 with AWSCredentialsProvider

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

the class AwsModuleTest method testAWSStaticCredentialsProviderSerializationDeserialization.

@Test
public void testAWSStaticCredentialsProviderSerializationDeserialization() throws Exception {
    String awsKeyId = "key-id";
    String awsSecretKey = "secret-key";
    AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsKeyId, awsSecretKey));
    String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
    AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(credentialsProvider.getCredentials().getAWSAccessKeyId(), deserializedCredentialsProvider.getCredentials().getAWSAccessKeyId());
    assertEquals(credentialsProvider.getCredentials().getAWSSecretKey(), deserializedCredentialsProvider.getCredentials().getAWSSecretKey());
    String sessionToken = "session-token";
    BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(awsKeyId, awsSecretKey, sessionToken);
    credentialsProvider = new AWSStaticCredentialsProvider(sessionCredentials);
    serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
    deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
    BasicSessionCredentials deserializedCredentials = (BasicSessionCredentials) deserializedCredentialsProvider.getCredentials();
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(deserializedCredentials.getAWSAccessKeyId(), awsKeyId);
    assertEquals(deserializedCredentials.getAWSSecretKey(), awsSecretKey);
    assertEquals(deserializedCredentials.getSessionToken(), sessionToken);
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) BasicSessionCredentials(com.amazonaws.auth.BasicSessionCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 55 with AWSCredentialsProvider

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

the class AwsModuleTest method testClasspathPropertiesFileCredentialsProviderSerializationDeserialization.

@Test
public void testClasspathPropertiesFileCredentialsProviderSerializationDeserialization() throws Exception {
    String credentialsFilePath = "/path/to/file";
    ClasspathPropertiesFileCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(credentialsFilePath);
    String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
    AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(credentialsFilePath, readField(deserializedCredentialsProvider, "credentialsFilePath", true));
}
Also used : ClasspathPropertiesFileCredentialsProvider(com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Aggregations

AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)125 Test (org.junit.Test)75 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)26 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)20 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)19 AWSCredentials (com.amazonaws.auth.AWSCredentials)16 TestRunner (org.apache.nifi.util.TestRunner)15 ClientConfiguration (com.amazonaws.ClientConfiguration)12 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)12 STSAssumeRoleSessionCredentialsProvider (com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider)8 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)8 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)8 AWSCredentialsProviderChain (com.amazonaws.auth.AWSCredentialsProviderChain)7 ClasspathPropertiesFileCredentialsProvider (com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider)7 EnvironmentVariableCredentialsProvider (com.amazonaws.auth.EnvironmentVariableCredentialsProvider)7 SystemPropertiesCredentialsProvider (com.amazonaws.auth.SystemPropertiesCredentialsProvider)7 ArrayList (java.util.ArrayList)7 Properties (java.util.Properties)7 Configuration (org.apache.hadoop.conf.Configuration)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7