Update existing proxy tests.
@@ -52,6 +52,14 @@ class BaseConnectionClassTestCase(unittest.TestCase):
self.assertIsNone(result[3])
self.assertIsNone(result[4])
+ proxy_url = 'https://127.0.0.2:3129'
+ result = conn._parse_proxy_url(proxy_url=proxy_url)
+ self.assertEqual(result[0], 'https')
+ self.assertEqual(result[1], '127.0.0.2')
+ self.assertEqual(result[2], 3129)
+ self.assertIsNone(result[3])
+ self.assertIsNone(result[4])
+
proxy_url = 'http://user1:pass1@127.0.0.1:3128'
result = conn._parse_proxy_url(proxy_url=proxy_url)
self.assertEqual(result[0], 'http')
@@ -60,6 +68,14 @@ class BaseConnectionClassTestCase(unittest.TestCase):
self.assertEqual(result[3], 'user1')
self.assertEqual(result[4], 'pass1')
+ proxy_url = 'https://user1:pass1@127.0.0.2:3129'
+ result = conn._parse_proxy_url(proxy_url=proxy_url)
+ self.assertEqual(result[0], 'https')
+ self.assertEqual(result[1], '127.0.0.2')
+ self.assertEqual(result[2], 3129)
+ self.assertEqual(result[3], 'user1')
+ self.assertEqual(result[4], 'pass1')
+
proxy_url = 'http://127.0.0.1'
expected_msg = 'proxy_url must be in the following format'
assertRaisesRegex(self, ValueError, expected_msg,
@@ -113,6 +129,14 @@ class BaseConnectionClassTestCase(unittest.TestCase):
self.assertEqual(conn.proxy_host, '127.0.0.5')
self.assertEqual(conn.proxy_port, 3128)
+ os.environ['http_proxy'] = proxy_url
+ proxy_url = 'https://127.0.0.6:3129'
+ conn = LibcloudConnection(host='localhost', port=80,
+ proxy_url=proxy_url)
+ self.assertEqual(conn.proxy_scheme, 'https')
+ self.assertEqual(conn.proxy_host, '127.0.0.6')
+ self.assertEqual(conn.proxy_port, 3129)
+
def test_connection_to_unusual_port(self):
conn = LibcloudConnection(host='localhost', port=8080)
self.assertIsNone(conn.proxy_scheme)
@@ -387,5 +411,6 @@ class CertificateConnectionClassTestCase(unittest.TestCase):
self.assertTrue(isinstance(adapter, SignedHTTPSAdapter))
self.assertEqual(adapter.cert_file, 'test.pem')
+
if __name__ == '__main__':
sys.exit(unittest.main())
