diff --git a/moto/s3/responses.py b/moto/s3/responses.py index cec2de6d9..a57522882 100644 --- a/moto/s3/responses.py +++ b/moto/s3/responses.py @@ -24,8 +24,11 @@ def parse_key_name(pth): return pth.lstrip("/") -def is_delete_keys(path, bucket_name): - return path == u'/?delete' +def is_delete_keys(request, path, bucket_name): + return path == u'/?delete' or ( + path == u'/' and + getattr(request, "query_string", "") == "delete" + ) class ResponseObject(_TemplateEnvironmentMixin): @@ -50,9 +53,9 @@ class ResponseObject(_TemplateEnvironmentMixin): def is_delete_keys(self, request, path, bucket_name): if self.subdomain_based_buckets(request): - return is_delete_keys(path, bucket_name) + return is_delete_keys(request, path, bucket_name) else: - return bucketpath_is_delete_keys(path, bucket_name) + return bucketpath_is_delete_keys(request, path, bucket_name) def parse_bucket_name_from_url(self, request, url): if self.subdomain_based_buckets(request): diff --git a/moto/s3bucket_path/utils.py b/moto/s3bucket_path/utils.py index 933c4f6d4..36aac78eb 100644 --- a/moto/s3bucket_path/utils.py +++ b/moto/s3bucket_path/utils.py @@ -15,5 +15,8 @@ def parse_key_name(path): return "/".join(path.rstrip("/").split("/")[2:]) -def is_delete_keys(path, bucket_name): - return path == u'/' + bucket_name + u'/?delete' +def is_delete_keys(request, path, bucket_name): + return path == u'/' + bucket_name + u'/?delete' or ( + path == u'/' + bucket_name and + getattr(request, "query_string", "") == "delete" + )