fix: validate and apply the ListBuckets bucket-region query

ListBuckets ignored bucket-region: a value that is not a region was
accepted, and a region other than the gateway one still listed every
bucket. S3 rejects an invalid value with 400 InvalidArgument, "Argument
value abc is not a valid AWS Region", and lists only the buckets of the
requested region.

Check bucket-region against the AWS region code format, always
accepting the gateway region whatever its name, and return an empty
list for any other region, since every bucket lives in the gateway
region. Enable the REST tests that cover both cases.

Fixes #1923
Fixes #1930
This commit is contained in:
dualfroz committed 2026-10-05 20:42:18 +02:00
1 parent 2bb327ec69
commit b7ff97181d
8 files changed
+175 -6

No files matched your search

+4
View File
@@ -110,6 +110,8 @@ func TestListBuckets(ts *TestState) {
ts.Sync(ListBuckets_as_admin)
ts.Sync(ListBuckets_with_prefix)
ts.Sync(ListBuckets_invalid_max_buckets)
ts.Sync(ListBuckets_invalid_bucket_region)
ts.Sync(ListBuckets_bucket_region)
ts.Sync(ListBuckets_truncated)
ts.Sync(ListBuckets_success)
ts.Sync(ListBuckets_empty_success)
@@ -2985,6 +2987,8 @@ func GetIntTests() IntTests {
"ListBuckets_as_admin": ListBuckets_as_admin,
"ListBuckets_with_prefix": ListBuckets_with_prefix,
"ListBuckets_invalid_max_buckets": ListBuckets_invalid_max_buckets,
"ListBuckets_invalid_bucket_region": ListBuckets_invalid_bucket_region,
"ListBuckets_bucket_region": ListBuckets_bucket_region,
"ListBuckets_truncated": ListBuckets_truncated,
"ListBuckets_success": ListBuckets_success,
"ListBuckets_empty_success": ListBuckets_empty_success,