]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa,test: decode return val of base64.b64encode()
authorKefu Chai <kchai@redhat.com>
Mon, 6 Apr 2020 10:55:53 +0000 (18:55 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jun 2020 11:56:59 +0000 (19:56 +0800)
base64.b64encode() returns bytes in Python3, and we will pass it as a
commandline parameter later on, which will be quoted. so the command
line can be consumed by shell. so before sending it to shell, we should
convert it to string.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 91b49ab39d7377e0816fa3c44e2cabed9ce14f12)

Conflicts:
qa/tasks/s3tests_java.py: trivial resolution

qa/tasks/ragweed.py
src/test/rgw/rgw_multi/zone_ps.py

index 624c81737f37bb0699e1d685cb106632c730d84d..5fff317396b573d2160bf1eda0174f2a48a5c67e 100644 (file)
@@ -8,6 +8,7 @@ import contextlib
 import logging
 import os
 import random
+import six
 import string
 
 from teuthology import misc as teuthology
@@ -102,7 +103,7 @@ def _config_user(ragweed_conf, section, user):
     ragweed_conf[section].setdefault('email', '{user}+test@test.test'.format(user=user))
     ragweed_conf[section].setdefault('display_name', 'Mr. {user}'.format(user=user))
     ragweed_conf[section].setdefault('access_key', ''.join(random.choice(string.ascii_uppercase) for i in range(20)))
-    ragweed_conf[section].setdefault('secret_key', base64.b64encode(os.urandom(40)))
+    ragweed_conf[section].setdefault('secret_key', base64.b64encode(os.urandom(40)).decode('ascii'))
 
 
 @contextlib.contextmanager
index 9c512b16498b53006a503476b0ab7b84864548ec..000bc41a389020a393f66706ddfb539adb9a6c92 100644 (file)
@@ -88,7 +88,7 @@ def make_request(conn, method, resource, parameters=None, sign_parameters=False,
         string_to_sign += url_params
     signature = base64.b64encode(hmac.new(conn.aws_secret_access_key,
                                           string_to_sign.encode('utf-8'),
-                                          hashlib.sha1).digest())
+                                          hashlib.sha1).digest()).decode('ascii')
     headers = {'Authorization': 'AWS '+conn.aws_access_key_id+':'+signature,
                'Date': string_date,
                'Host': conn.host+':'+str(conn.port)}
@@ -225,7 +225,7 @@ class PSTopicS3:
         log.debug('StringTosign: %s', string_to_sign) 
         signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key,
                                      string_to_sign.encode('utf-8'),
-                                     hashlib.sha1).digest())
+                                     hashlib.sha1).digest()).decode('ascii')
         headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature,
                    'Date': string_date,
                    'Host': self.conn.host+':'+str(self.conn.port),
@@ -267,7 +267,7 @@ class PSTopicS3:
         log.debug('StringTosign: %s', string_to_sign) 
         signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key,
                                      string_to_sign.encode('utf-8'),
-                                     hashlib.sha1).digest())
+                                     hashlib.sha1).digest()).decode('ascii')
         headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature,
                    'Date': string_date,
                    'Host': self.conn.host+':'+str(self.conn.port),