Raising MalformedXML exception when using boto3 client and s3.delete_objects()
This commit is contained in:
parent
108dc6b049
commit
f32db6e64a
@ -566,6 +566,8 @@ class ResponseObject(_TemplateEnvironmentMixin):
|
|||||||
keys = minidom.parseString(body).getElementsByTagName('Key')
|
keys = minidom.parseString(body).getElementsByTagName('Key')
|
||||||
deleted_names = []
|
deleted_names = []
|
||||||
error_names = []
|
error_names = []
|
||||||
|
if len(keys) == 0:
|
||||||
|
raise MalformedXML()
|
||||||
|
|
||||||
for k in keys:
|
for k in keys:
|
||||||
key_name = k.firstChild.nodeValue
|
key_name = k.firstChild.nodeValue
|
||||||
|
@ -648,6 +648,7 @@ def test_delete_keys_with_invalid():
|
|||||||
Key(bucket=bucket, name='file3').set_contents_from_string('abc')
|
Key(bucket=bucket, name='file3').set_contents_from_string('abc')
|
||||||
Key(bucket=bucket, name='file4').set_contents_from_string('abc')
|
Key(bucket=bucket, name='file4').set_contents_from_string('abc')
|
||||||
|
|
||||||
|
# non-existing key case
|
||||||
result = bucket.delete_keys(['abc', 'file3'])
|
result = bucket.delete_keys(['abc', 'file3'])
|
||||||
|
|
||||||
result.deleted.should.have.length_of(1)
|
result.deleted.should.have.length_of(1)
|
||||||
@ -656,6 +657,17 @@ def test_delete_keys_with_invalid():
|
|||||||
keys.should.have.length_of(3)
|
keys.should.have.length_of(3)
|
||||||
keys[0].name.should.equal('file1')
|
keys[0].name.should.equal('file1')
|
||||||
|
|
||||||
|
# empty keys and boto2 client
|
||||||
|
result = bucket.delete_keys([])
|
||||||
|
|
||||||
|
result.deleted.should.have.length_of(0)
|
||||||
|
result.errors.should.have.length_of(0)
|
||||||
|
|
||||||
|
# empty keys and boto3 client
|
||||||
|
with assert_raises(ClientError) as err:
|
||||||
|
boto3.client('s3').delete_objects(Bucket='foobar', Delete={'Objects': []})
|
||||||
|
assert err.exception.response["Error"]["Code"] == "MalformedXML"
|
||||||
|
|
||||||
|
|
||||||
@mock_s3_deprecated
|
@mock_s3_deprecated
|
||||||
def test_bucket_name_with_dot():
|
def test_bucket_name_with_dot():
|
||||||
|
Loading…
Reference in New Issue
Block a user