Skip to content

Commit

Permalink
Support @ServiceConnection endpoint attribute for S3Presigner
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalvarpe committed Dec 21, 2024
1 parent 425b6c8 commit 2990492
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ S3Presigner s3Presigner(S3Properties properties, AwsProperties awsProperties,
.credentialsProvider(credentialsProvider).region(AwsClientBuilderConfigurer.resolveRegion(properties,
connectionDetails.getIfAvailable(), regionProvider));

if (properties.getEndpoint() != null) {
builder.endpointOverride(properties.getEndpoint());
}
else if (awsProperties.getEndpoint() != null) {
builder.endpointOverride(awsProperties.getEndpoint());
}
Optional.ofNullable(properties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(awsProperties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(connectionDetails.getIfAvailable()).map(AwsConnectionDetails::getEndpoint).ifPresent(builder::endpointOverride);
Optional.ofNullable(awsProperties.getFipsEnabled()).ifPresent(builder::fipsEnabled);
Optional.ofNullable(awsProperties.getDualstackEnabled()).ifPresent(builder::dualstackEnabled);
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.awspring.cloud.autoconfigure.ses.SesAutoConfiguration;
import io.awspring.cloud.autoconfigure.sns.SnsAutoConfiguration;
import io.awspring.cloud.autoconfigure.sqs.SqsAutoConfiguration;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
Expand All @@ -40,10 +41,14 @@
import org.testcontainers.utility.DockerImageName;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest;
import software.amazon.awssdk.services.ses.SesClient;
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;

import java.time.Duration;

@SpringJUnitConfig
@Testcontainers(disabledWithoutDocker = true)
class AwsContainerConnectionDetailsFactoryTest {
Expand Down Expand Up @@ -88,6 +93,14 @@ void configuresS3ClientWithServiceConnection(@Autowired S3Client client) {
assertThatCode(client::listBuckets).doesNotThrowAnyException();
}

@Test
@Disabled
void configuresS3PresignerWithServiceConnection(@Autowired S3Presigner s3Presigner) {
assertThatCode(() -> s3Presigner.presignGetObject(req1 -> req1.signatureDuration(Duration.ofSeconds(2))
.getObjectRequest(req2 -> req2.bucket("my-bucket").build())))
.doesNotThrowAnyException();
}

@Configuration(proxyBeanMethods = false)
@ImportAutoConfiguration({ AwsAutoConfiguration.class, CredentialsProviderAutoConfiguration.class,
RegionProviderAutoConfiguration.class, DynamoDbAutoConfiguration.class, SesAutoConfiguration.class,
Expand Down

0 comments on commit 2990492

Please sign in to comment.