Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public S3AsyncClient s3Async() {
.applyMutation(
b -> s3FileIOProperties.applyCredentialConfigurations(awsClientProperties, b))
.applyMutation(s3FileIOProperties::applyEndpointConfigurations)
.applyMutation(s3FileIOProperties::applyServiceConfigurations)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,11 @@ private AwsCredentialsProvider getCredentialsProvider(AwsClientProperties awsCli
* <p>Sample usage:
*
* <pre>
* S3Client.builder().applyMutation(s3FileIOProperties::applyS3ServiceConfigurations)
* S3Client.builder().applyMutation(s3FileIOProperties::applyServiceConfigurations)
* S3AsyncClient.builder().applyMutation(s3FileIOProperties::applyServiceConfigurations)
* </pre>
*/
public <T extends S3ClientBuilder> void applyServiceConfigurations(T builder) {
public <T extends S3BaseClientBuilder<T, ?>> void applyServiceConfigurations(T builder) {
builder
.dualstackEnabled(isDualStackEnabled)
.crossRegionAccessEnabled(isCrossRegionAccessEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,44 @@ public void testApplyS3ServiceConfigurations() {
.isFalse();
}

@Test
public void testApplyS3AsyncServiceConfigurations() {
Map<String, String> properties = Maps.newHashMap();
properties.put(S3FileIOProperties.DUALSTACK_ENABLED, "true");
properties.put(S3FileIOProperties.CROSS_REGION_ACCESS_ENABLED, "true");
properties.put(S3FileIOProperties.PATH_STYLE_ACCESS, "true");
properties.put(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true");
properties.put(S3FileIOProperties.ACCELERATION_ENABLED, "false");
S3FileIOProperties s3FileIOProperties = new S3FileIOProperties(properties);
S3AsyncClientBuilder mockBuilder = Mockito.mock(S3AsyncClientBuilder.class);

ArgumentCaptor<S3Configuration> s3ConfigurationCaptor =
ArgumentCaptor.forClass(S3Configuration.class);

Mockito.doReturn(mockBuilder).when(mockBuilder).dualstackEnabled(Mockito.anyBoolean());
Mockito.doReturn(mockBuilder)
.when(mockBuilder)
.crossRegionAccessEnabled(Mockito.anyBoolean());
Mockito.doReturn(mockBuilder)
.when(mockBuilder)
.serviceConfiguration(Mockito.any(S3Configuration.class));

s3FileIOProperties.applyServiceConfigurations(mockBuilder);

Mockito.verify(mockBuilder).serviceConfiguration(s3ConfigurationCaptor.capture());

S3Configuration s3Configuration = s3ConfigurationCaptor.getValue();
assertThat(s3Configuration.pathStyleAccessEnabled())
.as("s3 async path style access enabled parameter should be set to true")
.isTrue();
assertThat(s3Configuration.useArnRegionEnabled())
.as("s3 async use arn region enabled parameter should be set to true")
.isTrue();
assertThat(s3Configuration.accelerateModeEnabled())
.as("s3 async acceleration mode enabled parameter should be set to false")
.isFalse();
}

@Test
public void testApplySignerConfiguration() {
Map<String, String> properties =
Expand Down