use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class BasicSnsClientProviderTest method testSerialization.
@Test
public void testSerialization() {
AwsCredentialsProvider awsCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create("ACCESS_KEY_ID", "SECRET_ACCESS_KEY"));
BasicSnsClientProvider snsClientProvider = new BasicSnsClientProvider(awsCredentialsProvider, "us-east-1", null);
byte[] serializedBytes = SerializableUtils.serializeToByteArray(snsClientProvider);
BasicSnsClientProvider snsClientProviderDeserialized = (BasicSnsClientProvider) SerializableUtils.deserializeFromByteArray(serializedBytes, "Aws Credentials Provider");
assertEquals(snsClientProvider, snsClientProviderDeserialized);
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class DefaultS3ClientBuilderFactoryTest method testSetCredentialsProvider.
@Test
public void testSetCredentialsProvider() {
AwsCredentialsProvider credentialsProvider = mock(AwsCredentialsProvider.class);
when(s3Options.getAwsCredentialsProvider()).thenReturn(credentialsProvider);
DefaultS3ClientBuilderFactory.createBuilder(builder, s3Options);
verify(builder).credentialsProvider(credentialsProvider);
verifyNoMoreInteractions(builder);
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class AwsModuleTest method testAwsCredentialsProviderSerializationDeserialization.
@Test
public void testAwsCredentialsProviderSerializationDeserialization() throws Exception {
AwsCredentialsProvider provider = DefaultCredentialsProvider.create();
AwsCredentialsProvider deserializedProvider = serializeAndDeserialize(provider);
assertEquals(provider.getClass(), deserializedProvider.getClass());
provider = EnvironmentVariableCredentialsProvider.create();
deserializedProvider = serializeAndDeserialize(provider);
assertEquals(provider.getClass(), deserializedProvider.getClass());
provider = SystemPropertyCredentialsProvider.create();
deserializedProvider = serializeAndDeserialize(provider);
assertEquals(provider.getClass(), deserializedProvider.getClass());
provider = ProfileCredentialsProvider.create();
deserializedProvider = serializeAndDeserialize(provider);
assertEquals(provider.getClass(), deserializedProvider.getClass());
provider = ContainerCredentialsProvider.builder().build();
deserializedProvider = serializeAndDeserialize(provider);
assertEquals(provider.getClass(), deserializedProvider.getClass());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class AwsModuleTest method testStsAssumeRoleCredentialsProviderSerializationDeserialization.
@Test
public void testStsAssumeRoleCredentialsProviderSerializationDeserialization() throws Exception {
AssumeRoleRequest req = AssumeRoleRequest.builder().roleArn("roleArn").policy("policy").build();
Supplier<AwsCredentialsProvider> provider = () -> StsAssumeRoleCredentialsProvider.builder().stsClient(StsClient.create()).refreshRequest(req).build();
Properties overrides = new Properties();
overrides.setProperty(AWS_REGION.property(), Regions.US_EAST_1.getName());
overrides.setProperty(AWS_ACCESS_KEY_ID.property(), "key");
overrides.setProperty(AWS_SECRET_ACCESS_KEY.property(), "secret");
// Region and credentials for STS client are resolved using default providers
AwsCredentialsProvider deserializedProvider = withSystemPropertyOverrides(overrides, () -> serializeAndDeserialize(provider.get()));
Supplier<AssumeRoleRequest> requestSupplier = (Supplier<AssumeRoleRequest>) readField(deserializedProvider, "assumeRoleRequestSupplier", true);
assertThat(requestSupplier.get()).isEqualTo(req);
}
use of software.amazon.awssdk.auth.credentials.AwsCredentialsProvider in project beam by apache.
the class AwsSerializableUtilsTest method testFailOnAwsCredentialsProviderSerialization.
@Test(expected = IllegalArgumentException.class)
public void testFailOnAwsCredentialsProviderSerialization() {
AwsCredentialsProvider awsCredentialsProvider = new UnknownAwsCredentialsProvider();
AwsSerializableUtils.serializeAwsCredentialsProvider(awsCredentialsProvider);
}
Aggregations