mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-23 13:38:38 +00:00
Fix test_bucket_list_prefix_unreadable
Following https://github.com/boto/botocore/pull/726, list_objects will automatically include a encoding-type=url query param. However, the client does not decode all of the response elements properly -- notably, Prefix would remain encoded. Hopefully this will be fixed soon-ish (I've got a patch proposed at https://github.com/boto/botocore/pull/1901) but in the meantime, use the work-around suggested in https://github.com/boto/boto3/issues/816 of unregistering the set_list_objects_encoding_type_url handler. Signed-off-by: Tim Burke <tim.burke@gmail.com>
This commit is contained in:
parent
76beb672d1
commit
c0f90da1c4
1 changed files with 7 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import boto3
|
import boto3
|
||||||
|
import botocore.handlers
|
||||||
import botocore.session
|
import botocore.session
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from botocore.exceptions import ParamValidationError
|
from botocore.exceptions import ParamValidationError
|
||||||
|
@ -977,6 +978,12 @@ def test_bucket_list_prefix_unreadable():
|
||||||
key_names = ['foo/bar', 'foo/baz', 'quux']
|
key_names = ['foo/bar', 'foo/baz', 'quux']
|
||||||
bucket_name = _create_objects(keys=key_names)
|
bucket_name = _create_objects(keys=key_names)
|
||||||
client = get_client()
|
client = get_client()
|
||||||
|
# (Some versions of) botocore will include encoding-type=url
|
||||||
|
# but not decode the reflected Prefix. Work around that.
|
||||||
|
if hasattr(botocore.handlers, 'set_list_objects_encoding_type_url'):
|
||||||
|
client.meta.events.unregister(
|
||||||
|
'before-parameter-build.s3.ListObjects',
|
||||||
|
botocore.handlers.set_list_objects_encoding_type_url)
|
||||||
|
|
||||||
response = client.list_objects(Bucket=bucket_name, Prefix='\x0a')
|
response = client.list_objects(Bucket=bucket_name, Prefix='\x0a')
|
||||||
eq(response['Prefix'], '\x0a')
|
eq(response['Prefix'], '\x0a')
|
||||||
|
|
Loading…
Reference in a new issue