Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @ServiceConnection endpoint attribute for S3Presigner #1310

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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 @@ -56,6 +56,7 @@
*
* @author Maciej Walkowiak
* @author Matej Nedic
* @author Kunal Varpe
*/
@AutoConfiguration
@ConditionalOnClass({ S3Client.class, S3OutputStreamProvider.class })
Expand Down Expand Up @@ -116,6 +117,10 @@ S3Presigner s3Presigner(S3Properties properties, AwsProperties awsProperties,
else if (awsProperties.getEndpoint() != null) {
builder.endpointOverride(awsProperties.getEndpoint());
}
else if (connectionDetails.getIfAvailable() != null
&& connectionDetails.getIfAvailable().getEndpoint() != null) {
builder.endpointOverride(connectionDetails.getIfAvailable().getEndpoint());
}
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 java.time.Duration;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
Expand All @@ -40,6 +41,7 @@
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.ses.SesClient;
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
Expand Down Expand Up @@ -88,6 +90,12 @@ void configuresS3ClientWithServiceConnection(@Autowired S3Client client) {
assertThatCode(client::listBuckets).doesNotThrowAnyException();
}

@Test
void configuresS3PresignerWithServiceConnection(@Autowired S3Presigner s3Presigner) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejwalkowiak @MatejNedic
I have disabled this test because I am uncertain how to verify that the S3Presigner correctly references the endpoint property from the ServiceConnection. I noticed that most client tests simply call one of the basic methods and ensure that the call does not result in an exception.

In this case, I attempted to use the presignGetObject method for verification. However, this method requires several parameters to be set up, and it might also necessitate configuring an S3 bucket prior to running the test. This has left me uncertain whether my approach is correct. I would appreciate your opinion or guidance on how to proceed with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejwalkowiak @MatejNedic @tomazfernandes
I have fixed the test, please let me know if I have validated test correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejwalkowiak @MatejNedic @tomazfernandes
Is there any way to retry the pipeline, because the test which is failing in the CI process is passing locally.

assertThatCode(() -> s3Presigner.presignGetObject(req1 -> req1.signatureDuration(Duration.ofSeconds(2))
.getObjectRequest(req2 -> req2.bucket("my-bucket").key("test").build()))).doesNotThrowAnyException();
}

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