Permalink
Browse files

restructure ssl tests

  • Loading branch information...
1 parent 82cee12 commit 61fd1496090e5aef652a2f1feebc832a20ceb5aa @t-8ch t-8ch committed Apr 5, 2013
Showing with 23 additions and 28 deletions.
  1. +23 −28 test/with_dummyserver/test_https.py
@@ -93,16 +93,6 @@ def test_cert_reqs_as_short_string(self):
# if we pass in an invalid value it defaults to CERT_NONE
self.assertRaises(SSLError, https_pool.request, 'GET', '/')
- def test_ssl_version_as_string(self):
- self._pool.ssl_version = 'PROTOCOL_TLSv1'
- r = self._pool.request('GET', '/')
- self.assertEqual(r.status, 200, r.data)
-
- def test_ssl_version_as_short_string(self):
- self._pool.ssl_version = 'TLSv1'
- r = self._pool.request('GET', '/')
- self.assertEqual(r.status, 200, r.data)
-
def test_ssl_unverified_with_ca_certs(self):
https_pool = HTTPSConnectionPool(self.host, self.port,
cert_reqs='CERT_NONE')
@@ -125,18 +115,6 @@ def test_invalid_ca_certs(self):
self.assertRaises(SSLError, https_pool.request, 'GET', '/')
-
-class TestHTTPS_TLSv1(HTTPSDummyServerTestCase):
- certs = DEFAULT_CERTS.copy()
- certs['ssl_version'] = ssl.PROTOCOL_TLSv1
-
- def setUp(self):
- self._pool = HTTPSConnectionPool(self.host, self.port)
-
- def test_set_ssl_version_to_sslv3(self):
- self._pool.ssl_version = ssl.PROTOCOL_SSLv3
- self.assertRaises(SSLError, self._pool.request, 'GET', '/')
-
def test_assert_specific_hostname(self):
https_pool = HTTPSConnectionPool('127.0.0.1', self.port,
cert_reqs='CERT_REQUIRED')
@@ -171,20 +149,37 @@ def test_assert_invalid_fingerprint(self):
https_pool.assert_fingerprint = 'AA:AA:AA:AA:AA:AAAA:AA:AAAA:AA:' \
'AA:AA:AA:AA:AA:AA:AA:AA:AA'
- self.assertRaises(SSLError,
- https_pool.request, 'GET', '/')
+ self.assertRaises(SSLError, https_pool.request, 'GET', '/')
# invalid length
https_pool.assert_fingerprint = 'AA'
- self.assertRaises(SSLError,
- https_pool.request, 'GET', '/')
+ self.assertRaises(SSLError, https_pool.request, 'GET', '/')
# uneven length
https_pool.assert_fingerprint = 'AA:A'
- self.assertRaises(SSLError,
- https_pool.request, 'GET', '/')
+ self.assertRaises(SSLError, https_pool.request, 'GET', '/')
+
+
+class TestHTTPS_TLSv1(HTTPSDummyServerTestCase):
+ certs = DEFAULT_CERTS.copy()
+ certs['ssl_version'] = ssl.PROTOCOL_TLSv1
+
+ def setUp(self):
+ self._pool = HTTPSConnectionPool(self.host, self.port)
+
+ def test_set_ssl_version_to_sslv3(self):
+ self._pool.ssl_version = ssl.PROTOCOL_SSLv3
+ self.assertRaises(SSLError, self._pool.request, 'GET', '/')
+
+ def test_ssl_version_as_string(self):
+ self._pool.ssl_version = 'PROTOCOL_SSLv3'
+ self.assertRaises(SSLError, self._pool.request, 'GET', '/')
+
+ def test_ssl_version_as_short_string(self):
+ self._pool.ssl_version = 'SSLv3'
+ self.assertRaises(SSLError, self._pool.request, 'GET', '/')
if __name__ == '__main__':

0 comments on commit 61fd149

Please sign in to comment.