summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorTristan Cacqueray <tristan.cacqueray@enovance.com>2014-01-24 17:40:16 +0100
committerTristan Cacqueray <tristan.cacqueray@enovance.com>2014-02-12 13:21:26 +0100
commitb182112719ab87942472e44aa3446ea0eb19a289 (patch)
tree8663d755145df6b64bc6b766866ebdb06639119a /tests/test_utils.py
parent9b73547b7de004fe623e454c425e9deee5d3d0ca (diff)
downloadpython-swiftclient-b182112719ab87942472e44aa3446ea0eb19a289.tar.gz
Port to python-requests
Currently, httplib implementation does not support SSL certificate verification. This patch fixes this. Note that ssl compression parameter and 100-continue thing is still missing from requests, though those are lower priority. Requests now takes care of: * proxy configuration (get_environ_proxies), * chunked encoding (with data generator), * bulk uploading (with files dictionary), * SSL certificate verification (with 'insecure' and 'cacert' parameter). This patch have been tested with requests 1.1.0 (CentOS 6) and requests 2.2.1 (current version). Change-Id: Ib5de962f4102d57c71ad85fd81a615362ef175dc Closes-Bug: #1199783 DocImpact SecurityImpact
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py80
1 files changed, 0 insertions, 80 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 7b2ef76..33d9467 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -14,7 +14,6 @@
# limitations under the License.
import testtools
-import os
from swiftclient import utils as u
@@ -118,82 +117,3 @@ class TestPrtBytes(testtools.TestCase):
def test_overflow(self):
bytes_ = 2 ** 90
self.assertEqual('1024Y', u.prt_bytes(bytes_, True).lstrip())
-
-
-class TestGetEnvironProxy(testtools.TestCase):
-
- ENV_VARS = ('http_proxy', 'https_proxy', 'no_proxy',
- 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY')
-
- def setUp(self):
- self.proxy_dict = {}
- super(TestGetEnvironProxy, self).setUp()
- for proxy_s in TestGetEnvironProxy.ENV_VARS:
- # Save old env value
- self.proxy_dict[proxy_s] = os.environ.get(proxy_s, None)
-
- def tearDown(self):
- super(TestGetEnvironProxy, self).tearDown()
- for proxy_s in TestGetEnvironProxy.ENV_VARS:
- if self.proxy_dict[proxy_s]:
- os.environ[proxy_s] = self.proxy_dict[proxy_s]
- elif os.environ.get(proxy_s):
- del os.environ[proxy_s]
-
- def setup_env(self, new_env={}):
- for proxy_s in TestGetEnvironProxy.ENV_VARS:
- # Set new env value
- if new_env.get(proxy_s):
- os.environ[proxy_s] = new_env.get(proxy_s)
- elif os.environ.get(proxy_s):
- del os.environ[proxy_s]
-
- def test_http_proxy(self):
- self.setup_env({'http_proxy': 'http://proxy.tests.com:8080'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['http'], 'http://proxy.tests.com:8080')
- self.assertEqual(proxy_dict.get('https'), None)
- self.assertEqual(len(proxy_dict), 1)
- self.setup_env({'HTTP_PROXY': 'http://proxy.tests.com:8080'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['http'], 'http://proxy.tests.com:8080')
- self.assertEqual(proxy_dict.get('https'), None)
- self.assertEqual(len(proxy_dict), 1)
-
- def test_https_proxy(self):
- self.setup_env({'https_proxy': 'http://proxy.tests.com:8080'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['https'], 'http://proxy.tests.com:8080')
- self.assertEqual(proxy_dict.get('http'), None)
- self.assertEqual(len(proxy_dict), 1)
- self.setup_env({'HTTPS_PROXY': 'http://proxy.tests.com:8080'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['https'], 'http://proxy.tests.com:8080')
- self.assertEqual(proxy_dict.get('http'), None)
- self.assertEqual(len(proxy_dict), 1)
-
- def test_http_https_proxy(self):
- self.setup_env({'http_proxy': 'http://proxy1.tests.com:8081',
- 'https_proxy': 'http://proxy2.tests.com:8082'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['http'], 'http://proxy1.tests.com:8081')
- self.assertEqual(proxy_dict['https'], 'http://proxy2.tests.com:8082')
- self.assertEqual(len(proxy_dict), 2)
- self.setup_env({'http_proxy': 'http://proxy1.tests.com:8081',
- 'HTTPS_PROXY': 'http://proxy2.tests.com:8082'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(proxy_dict['http'], 'http://proxy1.tests.com:8081')
- self.assertEqual(proxy_dict['https'], 'http://proxy2.tests.com:8082')
- self.assertEqual(len(proxy_dict), 2)
-
- def test_proxy_exclusion(self):
- self.setup_env({'http_proxy': 'http://proxy1.tests.com:8081',
- 'https_proxy': 'http://proxy2.tests.com:8082',
- 'no_proxy': 'www.tests.com'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(len(proxy_dict), 0)
- self.setup_env({'http_proxy': 'http://proxy1.tests.com:8081',
- 'HTTPS_PROXY': 'http://proxy2.tests.com:8082',
- 'NO_PROXY': 'www.tests.com'})
- proxy_dict = u.get_environ_proxies('www.tests.com:81')
- self.assertEqual(len(proxy_dict), 0)