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