]> git-server-git.apps.pok.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>
Sun, 14 Jun 2020 08:34:52 +0000 (16:34 +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)

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

index 2df0f959e2be0bdf5997759d801ab69b3c5e1446..696fc731b6d0dd687a9f91e56a846dce9cee95f2 100644 (file)
@@ -8,6 +8,7 @@ import contextlib
 import logging
 import os
 import random
+import six
 import string
 
 from teuthology import misc as teuthology
@@ -101,7 +102,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 a93a90e5409b2aefad1f7124195f976382b877c1..cf20c1b608d2665cd306c3656436c12cbc0ebf75 100644 (file)
@@ -239,7 +239,7 @@ class S3tests_java(Task):
         """
         access_key = ''.join(random.choice(string.ascii_uppercase)
                              for i in range(20))
-        access_secret = base64.b64encode(os.urandom(40))
+        access_secret = base64.b64encode(os.urandom(40)).decode('ascii')
         endpoint = self.ctx.rgw.role_endpoints.get(client)
 
         self._set_cfg_entry(
index 3f40dce8acebeb7d37030eb89136d6a18e1b779f..2ae49a6621caaf5d69c5c0ed22db61ee42fb6b09 100644 (file)
@@ -84,7 +84,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.encode('utf-8'),
                                           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)}
@@ -221,7 +221,7 @@ class PSTopicS3:
         log.debug('StringTosign: %s', string_to_sign) 
         signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key.encode('utf-8'),
                                      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),
@@ -263,7 +263,7 @@ class PSTopicS3:
         log.debug('StringTosign: %s', string_to_sign) 
         signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key.encode('utf-8'),
                                      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),