utf 8 in key deletions V2 (#1321)

* supporting utf-8 in key deletions

* Fixed decoding of version body when regexing

* Fixed some more random errors

* Possible fix

* Fixed unused import

* Added UTF comment Py2
This commit is contained in:
Terry Cain 2017-11-06 21:39:08 +00:00 committed by Jack Danger
commit d4745a575b
3 changed files with 68 additions and 18 deletions

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import datetime
@ -1865,7 +1864,7 @@ def test_boto3_list_object_versions():
def test_boto3_delete_markers():
s3 = boto3.client('s3', region_name='us-east-1')
bucket_name = 'mybucket'
key = 'key-with-versions'
key = u'key-with-versions-and-unicode-ó'
s3.create_bucket(Bucket=bucket_name)
s3.put_bucket_versioning(
Bucket=bucket_name,
@ -1880,10 +1879,9 @@ def test_boto3_delete_markers():
Key=key,
Body=body
)
s3.delete_object(
Bucket=bucket_name,
Key=key
)
s3.delete_objects(Bucket=bucket_name, Delete={'Objects': [{'Key': key}]})
with assert_raises(ClientError) as e:
s3.get_object(
Bucket=bucket_name,
@ -1905,12 +1903,18 @@ def test_boto3_delete_markers():
Bucket=bucket_name
)
response['Versions'].should.have.length_of(2)
response['Versions'][-1]['IsLatest'].should.be.true
response['Versions'][0]['IsLatest'].should.be.false
[(key_metadata['Key'], key_metadata['VersionId'])
for key_metadata in response['Versions']].should.equal(
[('key-with-versions', '0'), ('key-with-versions', '1')]
)
# We've asserted there is only 2 records so one is newest, one is oldest
latest = list(filter(lambda item: item['IsLatest'], response['Versions']))[0]
oldest = list(filter(lambda item: not item['IsLatest'], response['Versions']))[0]
# Double check ordering of version ID's
latest['VersionId'].should.equal('1')
oldest['VersionId'].should.equal('0')
# Double check the name is still unicode
latest['Key'].should.equal('key-with-versions-and-unicode-ó')
oldest['Key'].should.equal('key-with-versions-and-unicode-ó')
@mock_s3