Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
Reason:
- Endpoint override conditions are added as else if blocks
- Removed the Disable test annotation as added correct test for validating aws connection details with s3 presigner.
  • Loading branch information
kunalvarpe committed Dec 23, 2024
1 parent 2990492 commit b68f9a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
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 @@ -110,9 +111,16 @@ S3Presigner s3Presigner(S3Properties properties, AwsProperties awsProperties,
.credentialsProvider(credentialsProvider).region(AwsClientBuilderConfigurer.resolveRegion(properties,
connectionDetails.getIfAvailable(), regionProvider));

Optional.ofNullable(properties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(awsProperties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(connectionDetails.getIfAvailable()).map(AwsConnectionDetails::getEndpoint).ifPresent(builder::endpointOverride);
if (properties.getEndpoint() != null) {
builder.endpointOverride(properties.getEndpoint());
}
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,7 +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 java.time.Duration;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
Expand All @@ -42,13 +42,10 @@
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 @@ -94,11 +91,9 @@ void configuresS3ClientWithServiceConnection(@Autowired S3Client client) {
}

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

@Configuration(proxyBeanMethods = false)
Expand Down

0 comments on commit b68f9a9

Please sign in to comment.