This repository was archived by the owner on Dec 4, 2023. It is now read-only.
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
listObjects only returns the first match #188
Open
Description
I have the following folder structure for my file-based S3Mock:
Searching my bucket with the "2020/12/30/" prefix returns one common prefix instead of 2.
api = new S3Mock.Builder()
.withFileBackend("src/test/resources/s3")
.withPort(8001)
.build();
api.start();
...
@Test
public void test_s3_setup() {
SdkHttpClient httpClient = UrlConnectionHttpClient.builder()
.connectionTimeout(Duration.ofSeconds(10))
.socketTimeout(Duration.ofSeconds(10))
.build();
S3Configuration config = S3Configuration.builder()
.pathStyleAccessEnabled(true)
.build();
S3Client client = S3Client.builder()
.endpointOverride(URI.create("http://localhost:8001"))
.credentialsProvider(AnonymousCredentialsProvider.create())
.httpClient(httpClient)
.serviceConfiguration(config)
.build();
ListObjectsRequest listObjectsRequest = ListObjectsRequest
.builder()
.bucket(BUCKET_NAME)
.prefix("2020/12/30/")
.delimiter("/")
.build();
ListObjectsRequest listObjectsRequestB = ListObjectsRequest
.builder()
.bucket(BUCKET_NAME)
.prefix("2020/12/30/BASELINE/")
.delimiter("/")
.build();
ListObjectsRequest listObjectsRequestT = ListObjectsRequest
.builder()
.bucket(BUCKET_NAME)
.prefix("2020/12/30/TEST/")
.delimiter("/")
.build();
List<String> buckets = client.listBuckets().buckets().stream().map(Bucket::name).collect(Collectors.toList());
assertTrue(buckets.contains(BUCKET_NAME)); // works
List<String> baseline = client.listObjects(listObjectsRequestB).commonPrefixes().stream()
.map(CommonPrefix::prefix).collect(Collectors.toList());
assertThat(baseline)
.isEqualTo(List.of("2020/12/30/BASELINE/BATCH_PRICING_INFO/")); // works
List<String> test = client.listObjects(listObjectsRequestT).commonPrefixes().stream()
.map(CommonPrefix::prefix).collect(Collectors.toList());
assertThat(test)
.isEqualTo(List.of("2020/12/30/TEST/BATCH_PRICING_INFO/")); // works
List<String> envs = client.listObjects(listObjectsRequest).commonPrefixes().stream()
.map(CommonPrefix::prefix).collect(Collectors.toList());
assertThat(envs)
.isEqualTo(List.of("2020/12/30/BASELINE/", "2020/12/30/TEST/")); // fails, the response only contains "2020/12/30/BASELINE/"
}
Metadata
Metadata
Assignees
Labels
No labels