From 9ccf88d95fa5d184c56ac638bed37c3e3101356d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 6 Apr 2020 23:08:59 +0800 Subject: [PATCH] qa/tasks: pass encoding to Key.get_content_as_string() we assume that boto.Key.get_content_as_string() returns str instead of bytes, and compare the return value with a string, so, to ensure that lhs and rhs are both strings, we need to decode the returned content. since we always store strings composed with ASCII, it's safe to use 'ascii' to decode them. Signed-off-by: Kefu Chai --- qa/tasks/radosgw_admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qa/tasks/radosgw_admin.py b/qa/tasks/radosgw_admin.py index 7904d9c189cd1..2cc85865fbc99 100644 --- a/qa/tasks/radosgw_admin.py +++ b/qa/tasks/radosgw_admin.py @@ -664,7 +664,7 @@ def task(ctx, config): rl.log_and_clear("put_obj", bucket_name, user1) # fetch it too (for usage stats presently) - s = key.get_contents_as_string() + s = key.get_contents_as_string(encoding='ascii') rl.log_and_clear("get_obj", bucket_name, user1) assert s == object_name # list bucket too (for usage stats presently) @@ -943,7 +943,7 @@ def task(ctx, config): # get bucket and object to test if user keys are preserved bucket = connection3.get_bucket(bucket_name + '6') - s = key1.get_contents_as_string() + s = key1.get_contents_as_string(encoding='ascii') rl.log_and_clear("get_obj", bucket_name + '6', user4) assert s == object_name1 @@ -975,12 +975,12 @@ def task(ctx, config): # test if user 2 and user4 can still access their bucket and objects after rename fails bucket = connection3.get_bucket(bucket_name + '6') - s = key1.get_contents_as_string() + s = key1.get_contents_as_string(encoding='ascii') rl.log_and_clear("get_obj", bucket_name + '6', user4) assert s == object_name1 bucket = connection2.get_bucket(bucket_name + '7') - s = key2.get_contents_as_string() + s = key2.get_contents_as_string(encoding='ascii') rl.log_and_clear("get_obj", bucket_name + '7', user2) assert s == object_name2 -- 2.39.5