|
12 | 12 | import software.amazon.awssdk.awscore.exception.AwsServiceException; |
13 | 13 | import software.amazon.awssdk.core.retry.RetryPolicyContext; |
14 | 14 | import software.amazon.awssdk.core.retry.conditions.RetryCondition; |
| 15 | +import software.amazon.awssdk.http.SdkHttpClient; |
15 | 16 | import software.amazon.awssdk.regions.Region; |
| 17 | +import software.amazon.awssdk.services.s3.S3Client; |
16 | 18 | import software.amazon.awssdk.services.s3.endpoints.S3EndpointParams; |
17 | 19 | import software.amazon.awssdk.services.s3.endpoints.internal.DefaultS3EndpointProvider; |
18 | 20 | import software.amazon.awssdk.services.s3.model.S3Exception; |
|
32 | 34 | import org.elasticsearch.watcher.ResourceWatcherService; |
33 | 35 |
|
34 | 36 | import java.io.IOException; |
| 37 | +import java.net.URI; |
35 | 38 | import java.util.concurrent.atomic.AtomicBoolean; |
36 | 39 |
|
| 40 | +import static org.hamcrest.Matchers.equalTo; |
37 | 41 | import static org.mockito.Mockito.mock; |
38 | 42 |
|
39 | 43 | public class S3ServiceTests extends ESTestCase { |
@@ -272,4 +276,22 @@ public void testGetClientRegionFallbackToUsEast1() { |
272 | 276 | ); |
273 | 277 | } |
274 | 278 | } |
| 279 | + |
| 280 | + public void testEndpointOverrideSchemeDefaultsToHttpsWhenNotSpecified() { |
| 281 | + final S3Service s3Service = new S3Service( |
| 282 | + mock(Environment.class), |
| 283 | + Settings.EMPTY, |
| 284 | + mock(ResourceWatcherService.class), |
| 285 | + () -> Region.of("es-test-region") |
| 286 | + ); |
| 287 | + final String endpointWithoutScheme = randomIdentifier() + ".ignore"; |
| 288 | + S3Client s3Client = s3Service.buildClient( |
| 289 | + S3ClientSettings.getClientSettings( |
| 290 | + Settings.builder().put("s3.client.test-client.endpoint", endpointWithoutScheme).build(), |
| 291 | + "test-client" |
| 292 | + ), |
| 293 | + mock(SdkHttpClient.class) |
| 294 | + ); |
| 295 | + assertThat(s3Client.serviceClientConfiguration().endpointOverride().get(), equalTo(URI.create("https://" + endpointWithoutScheme))); |
| 296 | + } |
275 | 297 | } |
0 commit comments