Skip to content

Commit

Permalink
Merge pull request #907 from adobe/880-aws-sdk-v2-path-style-access
Browse files Browse the repository at this point in the history
Let AWS SDKv2 use path style access
  • Loading branch information
afranken authored Nov 11, 2022
2 parents 08b992e + a1b4d5f commit 9d66d5b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ Version 2.x is JDK8 LTS bytecode compatible, with Docker and JUnit / direct Java

* Features and fixes
* Support restarting S3Mock with the `retainFilesOnExit` option enabled. (fixes #818)
* Let AWS SDKv2 use path style access (fixes #880)
* Starting with AWS SDKv2.18.x domain style access is the default. This is currently not
supported by S3Mock.

## 2.8.0
2.x is JDK8 LTS bytecode compatible, with Docker and JUnit / direct Java integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import software.amazon.awssdk.http.SdkHttpConfigurationOption
import software.amazon.awssdk.http.apache.ApacheHttpClient
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.s3.S3Client
import software.amazon.awssdk.services.s3.S3Configuration
import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest
import software.amazon.awssdk.services.s3.model.Bucket
import software.amazon.awssdk.services.s3.model.CreateBucketRequest
Expand Down Expand Up @@ -131,6 +132,7 @@ internal abstract class S3TestBase {
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKeyId, secretAccessKey))
)
.serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
.endpointOverride(URI.create(serviceEndpoint))
.httpClient(
ApacheHttpClient.builder().buildWithDefaults(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Adobe.
* Copyright 2017-2022 Adobe.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,7 @@
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.utils.AttributeMap;

/**
Expand Down Expand Up @@ -79,6 +80,7 @@ public S3Client createS3ClientV2() {
.region(Region.of("us-east-1"))
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create("foo", "bar")))
.serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
.endpointOverride(URI.create(getServiceEndpoint()))
.httpClient(UrlConnectionHttpClient.builder().buildWithDefaults(AttributeMap.builder()
.put(TRUST_ALL_CERTIFICATES, Boolean.TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
Expand Down Expand Up @@ -131,6 +132,7 @@ protected S3Client createS3ClientV2(String endpoint) {
.region(Region.of("us-east-1"))
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create("foo", "bar")))
.serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
.endpointOverride(URI.create(endpoint))
.httpClient(UrlConnectionHttpClient.builder().buildWithDefaults(
AttributeMap.builder().put(TRUST_ALL_CERTIFICATES, Boolean.TRUE).build()))
Expand Down

0 comments on commit 9d66d5b

Please sign in to comment.