|
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;
|
|
29 | 31 | import org.elasticsearch.watcher.ResourceWatcherService;
|
30 | 32 |
|
31 | 33 | import java.io.IOException;
|
| 34 | +import java.net.URI; |
32 | 35 | import java.util.concurrent.atomic.AtomicBoolean;
|
33 | 36 |
|
| 37 | +import static org.hamcrest.Matchers.equalTo; |
34 | 38 | import static org.mockito.Mockito.mock;
|
35 | 39 |
|
36 | 40 | public class S3ServiceTests extends ESTestCase {
|
@@ -217,4 +221,22 @@ public void testGetClientRegionFallbackToUsEast1() {
|
217 | 221 | );
|
218 | 222 | }
|
219 | 223 | }
|
| 224 | + |
| 225 | + public void testEndpointOverrideSchemeDefaultsToHttpsWhenNotSpecified() { |
| 226 | + final S3Service s3Service = new S3Service( |
| 227 | + mock(Environment.class), |
| 228 | + Settings.EMPTY, |
| 229 | + mock(ResourceWatcherService.class), |
| 230 | + () -> Region.of("es-test-region") |
| 231 | + ); |
| 232 | + final String endpointWithoutScheme = randomIdentifier() + ".ignore"; |
| 233 | + S3Client s3Client = s3Service.buildClient( |
| 234 | + S3ClientSettings.getClientSettings( |
| 235 | + Settings.builder().put("s3.client.test-client.endpoint", endpointWithoutScheme).build(), |
| 236 | + "test-client" |
| 237 | + ), |
| 238 | + mock(SdkHttpClient.class) |
| 239 | + ); |
| 240 | + assertThat(s3Client.serviceClientConfiguration().endpointOverride().get(), equalTo(URI.create("https://" + endpointWithoutScheme))); |
| 241 | + } |
220 | 242 | }
|
0 commit comments