S3 fixture should report 404 on unknown bucket (#31782)

Today, `AmazonS3Fixture` returns 403 on attempts to access any inappropriate
bucket, whether known or otherwise. In fact, S3 reports 404 on nonexistent
buckets and 403 on inaccessible ones. This change enhances `AmazonS3Fixture` to
distinguish these cases.
This commit is contained in:
David Turner 2018-07-04 10:48:00 +01:00 committed by GitHub
parent 3f2a241b7f
commit 18c17dfb35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -96,8 +96,13 @@ public class AmazonS3Fixture extends AbstractHttpFixture {
if (handler != null) {
final String bucket = request.getParam("bucket");
if (bucket != null && permittedBucket.equals(bucket) == false) {
// allow a null bucket to support bucket-free APIs
return newError(request.getId(), RestStatus.FORBIDDEN, "AccessDenied", "Bad bucket", "");
// allow a null bucket to support the multi-object-delete API which
// passes the bucket name in the host header instead of the URL.
if (buckets.containsKey(bucket)) {
return newError(request.getId(), RestStatus.FORBIDDEN, "AccessDenied", "Bad bucket", "");
} else {
return newBucketNotFoundError(request.getId(), bucket);
}
}
return handler.handle(request);
} else {

View File

@ -183,10 +183,6 @@ setup:
---
"Register a repository with a non existing bucket":
- skip:
version: all
reason: to be fixed
- do:
catch: /repository_exception/
snapshot.create_repository:

View File

@ -183,10 +183,6 @@ setup:
---
"Register a repository with a non existing bucket":
- skip:
version: all
reason: to be fixed
- do:
catch: /repository_exception/
snapshot.create_repository: