You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/10/06 19:34:47 UTC

[1/4] libcloud git commit: Test 'CA_CERTS_PATH defined as list' warning

Repository: libcloud
Updated Branches:
  refs/heads/trunk 8eab5d210 -> 2075b87f6


Test 'CA_CERTS_PATH defined as list' warning


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

Branch: refs/heads/trunk
Commit: c2e71ecb4c2b97d858eebac8cae384438338f268
Parents: 6333ca7
Author: Quentin Pradet <qu...@apache.org>
Authored: Tue Oct 3 09:24:00 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Oct 6 23:28:20 2017 +0400

----------------------------------------------------------------------
 libcloud/http.py           | 26 ++++++++++++++------------
 libcloud/test/test_http.py | 11 ++++++++++-
 2 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/c2e71ecb/libcloud/http.py
----------------------------------------------------------------------
diff --git a/libcloud/http.py b/libcloud/http.py
index b855b42..9149995 100644
--- a/libcloud/http.py
+++ b/libcloud/http.py
@@ -144,22 +144,24 @@ class LibcloudBaseConnection(object):
     def _setup_verify(self):
         self.verify = libcloud.security.VERIFY_SSL_CERT
 
-    def _setup_ca_cert(self):
+    def _setup_ca_cert(self, **kwargs):
+        # simulating keyword-only argument in Python 2
+        ca_certs_path = kwargs.get('ca_cert', libcloud.security.CA_CERTS_PATH)
+
         if self.verify is False:
             pass
         else:
-            if isinstance(libcloud.security.CA_CERTS_PATH, list):
-                if len(libcloud.security.CA_CERTS_PATH) > 1:
-                    msg = ('Providing a list of CA trusts is no longer '
-                           'supported since libcloud 2.0. Using the first '
-                           'element in the list. See '
-                           'http://libcloud.readthedocs.io/en/latest/other/'
-                           'changes_in_2_0.html#providing-a-list-of-ca-trusts-'
-                           'is-no-longer-supported')
-                    warnings.warn(msg)
-                self.ca_cert = libcloud.security.CA_CERTS_PATH[0]
+            if isinstance(ca_certs_path, list):
+                msg = (
+                    'Providing a list of CA trusts is no longer supported '
+                    'since libcloud 2.0. Using the first element in the list. '
+                    'See http://libcloud.readthedocs.io/en/latest/other/'
+                    'changes_in_2_0.html#providing-a-list-of-ca-trusts-is-no-'
+                    'longer-supported')
+                warnings.warn(msg, DeprecationWarning)
+                self.ca_cert = ca_certs_path[0]
             else:
-                self.ca_cert = libcloud.security.CA_CERTS_PATH
+                self.ca_cert = ca_certs_path
 
     def _setup_signing(self, cert_file=None, key_file=None):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/c2e71ecb/libcloud/test/test_http.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_http.py b/libcloud/test/test_http.py
index dbe742c..2e9eeb1 100644
--- a/libcloud/test/test_http.py
+++ b/libcloud/test/test_http.py
@@ -16,7 +16,7 @@
 import os
 import sys
 import os.path
-from mock import patch
+import warnings
 
 import libcloud.security
 
@@ -66,6 +66,15 @@ class TestHttpLibSSLTests(unittest.TestCase):
 
         self.assertEqual(libcloud.security.CA_CERTS_PATH, file_path)
 
+    def test_ca_cert_list_warning(self):
+        with warnings.catch_warnings(record=True) as w:
+            self.httplib_object.verify = True
+            self.httplib_object._setup_ca_cert(
+                ca_cert=[ORIGINAL_CA_CERTS_PATH])
+            self.assertEqual(self.httplib_object.ca_cert,
+                             ORIGINAL_CA_CERTS_PATH)
+            self.assertEqual(w[0].category, DeprecationWarning)
+
     def test_setup_ca_cert(self):
         # verify = False, _setup_ca_cert should be a no-op
         self.httplib_object.verify = False


[2/4] libcloud git commit: Cleanup test_http.py

Posted by qu...@apache.org.
Cleanup test_http.py


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

Branch: refs/heads/trunk
Commit: 6333ca7be6591ea2855a51fed5aa91a2bcbd7e9c
Parents: fa074d1
Author: Quentin Pradet <qu...@apache.org>
Authored: Tue Oct 3 09:23:38 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Oct 6 23:28:20 2017 +0400

----------------------------------------------------------------------
 libcloud/test/test_http.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/6333ca7b/libcloud/test/test_http.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_http.py b/libcloud/test/test_http.py
index 4da6454..dbe742c 100644
--- a/libcloud/test/test_http.py
+++ b/libcloud/test/test_http.py
@@ -25,14 +25,14 @@ from libcloud.http import LibcloudConnection
 
 from libcloud.test import unittest
 
-ORIGINAL_CA_CERS_PATH = libcloud.security.CA_CERTS_PATH
+ORIGINAL_CA_CERTS_PATH = libcloud.security.CA_CERTS_PATH
 
 
 class TestHttpLibSSLTests(unittest.TestCase):
 
     def setUp(self):
         libcloud.security.VERIFY_SSL_CERT = False
-        libcloud.security.CA_CERTS_PATH = ORIGINAL_CA_CERS_PATH
+        libcloud.security.CA_CERTS_PATH = ORIGINAL_CA_CERTS_PATH
         self.httplib_object = LibcloudConnection('foo.bar', port=80)
 
     def test_custom_ca_path_using_env_var_doesnt_exist(self):
@@ -66,8 +66,7 @@ class TestHttpLibSSLTests(unittest.TestCase):
 
         self.assertEqual(libcloud.security.CA_CERTS_PATH, file_path)
 
-    @patch('warnings.warn')
-    def test_setup_ca_cert(self, _):
+    def test_setup_ca_cert(self):
         # verify = False, _setup_ca_cert should be a no-op
         self.httplib_object.verify = False
         self.httplib_object._setup_ca_cert()


[3/4] libcloud git commit: Improve CA_CERTS_PATH defined as list warning

Posted by qu...@apache.org.
Improve CA_CERTS_PATH defined as list warning


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

Branch: refs/heads/trunk
Commit: fa074d1737d9c60bf1bce5a239217336583dd385
Parents: 8eab5d2
Author: Quentin Pradet <qu...@apache.org>
Authored: Mon Oct 2 08:36:22 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Oct 6 23:28:20 2017 +0400

----------------------------------------------------------------------
 libcloud/http.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/fa074d17/libcloud/http.py
----------------------------------------------------------------------
diff --git a/libcloud/http.py b/libcloud/http.py
index 567a2a2..b855b42 100644
--- a/libcloud/http.py
+++ b/libcloud/http.py
@@ -150,7 +150,13 @@ class LibcloudBaseConnection(object):
         else:
             if isinstance(libcloud.security.CA_CERTS_PATH, list):
                 if len(libcloud.security.CA_CERTS_PATH) > 1:
-                    warnings.warn('Only 1 certificate path is supported')
+                    msg = ('Providing a list of CA trusts is no longer '
+                           'supported since libcloud 2.0. Using the first '
+                           'element in the list. See '
+                           'http://libcloud.readthedocs.io/en/latest/other/'
+                           'changes_in_2_0.html#providing-a-list-of-ca-trusts-'
+                           'is-no-longer-supported')
+                    warnings.warn(msg)
                 self.ca_cert = libcloud.security.CA_CERTS_PATH[0]
             else:
                 self.ca_cert = libcloud.security.CA_CERTS_PATH


[4/4] libcloud git commit: Add changes for #1118

Posted by qu...@apache.org.
Add changes for #1118

Closes #1118


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

Branch: refs/heads/trunk
Commit: 2075b87f66cabe76083c601ee087088048cd9c41
Parents: c2e71ec
Author: Quentin Pradet <qu...@apache.org>
Authored: Fri Oct 6 23:31:00 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Oct 6 23:31:00 2017 +0400

----------------------------------------------------------------------
 CHANGES.rst | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/2075b87f/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d0dd67f..3d91b40 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,12 @@
 Changes in Apach Libcloud in development
 ----------------------------------------
 
+Common
+~~~~~~
+
+- Improve warning when CA_CERTS_PATH is incorrectly passed as a list (GITHUB-1118)
+  [Quentin Pradet]
+
 Compute
 ~~~~~~~