You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/01/10 04:03:28 UTC
[3/5] libcloud git commit: more tests for insecure and secure
connections
more tests for insecure and secure connections
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/72f1e19b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/72f1e19b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/72f1e19b
Branch: refs/heads/trunk
Commit: 72f1e19b7bf6f8bbe1cac504d5eb2da19808edb7
Parents: 1e5945f
Author: Anthony Shaw <an...@apache.org>
Authored: Tue Jan 10 12:48:59 2017 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Tue Jan 10 12:48:59 2017 +1100
----------------------------------------------------------------------
libcloud/test/test_connection.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/72f1e19b/libcloud/test/test_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_connection.py b/libcloud/test/test_connection.py
index 3c19c55..d58ff3f 100644
--- a/libcloud/test/test_connection.py
+++ b/libcloud/test/test_connection.py
@@ -110,6 +110,10 @@ class BaseConnectionClassTestCase(unittest.TestCase):
self.assertEqual(conn.host, 'http://localhost')
def test_secure_connection_unusual_port(self):
+ """
+ Test that the connection class will default to secure (https) even
+ when the port is an unusual (non 443, 80) number
+ """
conn = Connection(secure=True, host='localhost', port=8081)
conn.connect()
self.assertEqual(conn.connection.host, 'https://localhost:8081')
@@ -118,7 +122,32 @@ class BaseConnectionClassTestCase(unittest.TestCase):
conn2.connect()
self.assertEqual(conn2.connection.host, 'https://localhost:8081')
+ def test_secure_by_default(self):
+ """
+ Test that the connection class will default to secure (https)
+ """
+ conn = Connection(host='localhost', port=8081)
+ conn.connect()
+ self.assertEqual(conn.connection.host, 'https://localhost:8081')
+
+ def test_implicit_port(self):
+ """
+ Test that the port is not included in the URL if the protocol implies
+ the port, e.g. http implies 80
+ """
+ conn = Connection(secure=True, host='localhost', port=443)
+ conn.connect()
+ self.assertEqual(conn.connection.host, 'https://localhost')
+
+ conn2 = Connection(secure=False, host='localhost', port=80)
+ conn2.connect()
+ self.assertEqual(conn2.connection.host, 'http://localhost')
+
def test_insecure_connection_unusual_port(self):
+ """
+ Test that the connection will allow unusual ports and insecure
+ schemes
+ """
conn = Connection(secure=False, host='localhost', port=8081)
conn.connect()
self.assertEqual(conn.connection.host, 'http://localhost:8081')