Skip to content

Commit

Permalink
Fix test_bucket_list_prefix_unreadable
Browse files Browse the repository at this point in the history
Following boto/botocore#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
boto/botocore#1901) but in the meantime, use the
work-around suggested in boto/boto3#816 of
unregistering the set_list_objects_encoding_type_url handler.

Signed-off-by: Tim Burke <tim.burke@gmail.com>
  • Loading branch information
tipabu committed Apr 4, 2022
1 parent 76beb67 commit c0f90da
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions s3tests_boto3/functional/test_s3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import boto3
import botocore.handlers
import botocore.session
from botocore.exceptions import ClientError
from botocore.exceptions import ParamValidationError
Expand Down Expand Up @@ -977,6 +978,12 @@ def test_bucket_list_prefix_unreadable():
key_names = ['foo/bar', 'foo/baz', 'quux']
bucket_name = _create_objects(keys=key_names)
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')
eq(response['Prefix'], '\x0a')
Expand Down

0 comments on commit c0f90da

Please sign in to comment.