libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [4/5] libcloud git commit: add a test for the certificate connection class
Date Sun, 02 Apr 2017 01:55:23 GMT
add a test for the certificate connection class


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

Branch: refs/heads/trunk
Commit: 9065c626be3d96212463840989576181c3f547ae
Parents: 1a3d4d8
Author: Anthony Shaw <anthonyshaw@apache.org>
Authored: Sun Apr 2 11:50:21 2017 +1000
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Sun Apr 2 11:50:21 2017 +1000

----------------------------------------------------------------------
 libcloud/test/test_connection.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/9065c626/libcloud/test/test_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_connection.py b/libcloud/test/test_connection.py
index 8a4e9b6..5907e83 100644
--- a/libcloud/test/test_connection.py
+++ b/libcloud/test/test_connection.py
@@ -24,9 +24,10 @@ from mock import Mock, patch
 import requests_mock
 
 from libcloud.test import unittest
-from libcloud.common.base import Connection
+from libcloud.common.base import Connection, CertificateConnection
 from libcloud.httplib_ssl import LibcloudBaseConnection
 from libcloud.httplib_ssl import LibcloudConnection
+from libcloud.httplib_ssl import SignedHTTPSAdapter
 from libcloud.utils.misc import retry
 
 
@@ -363,5 +364,17 @@ class ConnectionClassTestCase(unittest.TestCase):
             self.assertGreater(mock_connect.call_count, 1,
                                'Retry logic failed')
 
+
+class CertificateConnectionClassTestCase(unittest.TestCase):
+    def setUp(self):
+        self.connection = CertificateConnection(cert_file='test.pem',
+                                                url='https://test.com/test')
+        self.connection.connect()
+
+    def test_adapter_internals(self):
+        adapter = self.connection.connection.session.adapters['https://']
+        self.assertTrue(isinstance(adapter, SignedHTTPSAdapter))
+        self.assertEqual(adapter.cert_file, 'test.pem')
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message