Merge "https: Prevent leaking sockets for some operations"
This commit is contained in:
+12
-9
@@ -158,7 +158,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
self.assertEqual('0.0.0.0', cert.get_subject().commonName)
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('0.0.0.0', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
@@ -173,7 +173,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
self.assertEqual('*.pong.example.com', cert.get_subject().commonName)
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('ping.pong.example.com', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
@@ -188,13 +188,13 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
self.assertEqual('0.0.0.0', cert.get_subject().commonName)
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('alt1.example.com', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('alt2.example.com', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
@@ -209,19 +209,19 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
self.assertEqual('0.0.0.0', cert.get_subject().commonName)
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('alt1.example.com', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('alt2.example.com', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
except Exception:
|
||||
self.fail('Unexpected exception.')
|
||||
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('alt3.example.net', 0)
|
||||
conn.verify_callback(None, cert, 0, 0, 1)
|
||||
https.do_verify_callback(None, cert, 0, 0, 1, host=conn.host)
|
||||
self.fail('Failed to raise assertion.')
|
||||
except exc.SSLCertificateError:
|
||||
pass
|
||||
@@ -241,7 +241,8 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
self.fail('Failed to init VerifiedHTTPSConnection.')
|
||||
|
||||
self.assertRaises(exc.SSLCertificateError,
|
||||
conn.verify_callback, None, cert, 0, 0, 1)
|
||||
https.do_verify_callback, None, cert, 0, 0, 1,
|
||||
host=conn.host)
|
||||
|
||||
def test_ssl_expired_cert(self):
|
||||
"""
|
||||
@@ -256,9 +257,11 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
|
||||
try:
|
||||
conn = https.VerifiedHTTPSConnection('openstack.example.com', 0)
|
||||
except Exception:
|
||||
raise
|
||||
self.fail('Failed to init VerifiedHTTPSConnection.')
|
||||
self.assertRaises(exc.SSLCertificateError,
|
||||
conn.verify_callback, None, cert, 0, 0, 1)
|
||||
https.do_verify_callback, None, cert, 0, 0, 1,
|
||||
host=conn.host)
|
||||
|
||||
def test_ssl_broken_key_file(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user