Skip to content

Commit

Permalink
S3 fixture should report 404 on unknown bucket (#31782)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DaveCTurner authored Jul 4, 2018
1 parent 3f2a241 commit 18c17df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ protected Response handle(final Request request) throws IOException {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 18c17df

Please sign in to comment.