libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [3/4] libcloud git commit: Throw on invalid signature_version and make sure the argument is always a string.
Date Fri, 13 May 2016 09:50:39 GMT
Throw on invalid signature_version and make sure the argument is always a
string.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/09638edf
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/09638edf
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/09638edf

Branch: refs/heads/trunk
Commit: 09638edf4ddac08de38f7894f817dc83ac51fb1a
Parents: 35f3c0b
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Fri May 13 10:13:10 2016 +0200
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Fri May 13 10:33:28 2016 +0200

----------------------------------------------------------------------
 libcloud/storage/drivers/s3.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/09638edf/libcloud/storage/drivers/s3.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py
index df5eda7..6a16751 100644
--- a/libcloud/storage/drivers/s3.py
+++ b/libcloud/storage/drivers/s3.py
@@ -1055,14 +1055,22 @@ class S3RGWOutscaleStorageDriver(S3StorageDriver):
                  **kwargs):
         if region not in S3_RGW_OUTSCALE_HOSTS_BY_REGION:
             raise LibcloudError('Unknown region (%s)' % (region), driver=self)
+
         self.name = 'OUTSCALE Ceph RGW S3 (%s)' % (region)
         self.ex_location_name = region
         self.region_name = region
-        self.signature_version =\
-            kwargs.pop('signature_version', DEFAULT_SIGNATURE_VERSION)
-        self.connectionCls = S3RGWOutscaleConnectionAWS2
-        if self.signature_version == '4':
+        self.signature_version = str(kwargs.pop('signature_version',
+                                                DEFAULT_SIGNATURE_VERSION))
+
+        if self.signature_version not in ['2', '4']:
+            raise ValueError('Invalid signature_version: %s' %
+                             (self.signature_version))
+
+        if self.signature_version == '2':
+            self.connectionCls = S3RGWOutscaleConnectionAWS2
+        elif self.signature_version == '4':
             self.connectionCls = S3RGWOutscaleConnectionAWS4
+
         host = S3_RGW_OUTSCALE_HOSTS_BY_REGION[region]
         self.connectionCls.host = host
         super(S3RGWOutscaleStorageDriver, self).__init__(key, secret,


Mime
View raw message