]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Check that the default certificates file exists in a unit test.
authorBen Darnell <ben@bendarnell.com>
Sun, 20 Feb 2011 20:33:00 +0000 (12:33 -0800)
committerBen Darnell <ben@bendarnell.com>
Sun, 20 Feb 2011 20:33:00 +0000 (12:33 -0800)
tornado/simple_httpclient.py
tornado/test/simple_httpclient_test.py

index d6be72fc659a2b76dd97e0368b632f59f2624b4b..3a7884ef220fa20a61fc5b1f834c691218c96ee3 100644 (file)
@@ -27,6 +27,8 @@ try:
 except ImportError:
     ssl = None
 
+_DEFAULT_CA_CERTS = os.path.dirname(__file__) + '/ca-certificates.crt'
+
 class SimpleAsyncHTTPClient(object):
     """Non-blocking HTTP client with no external dependencies.
 
@@ -156,8 +158,7 @@ class _HTTPConnection(object):
                 if request.ca_certs is not None:
                     ssl_options["ca_certs"] = request.ca_certs
                 else:
-                    ssl_options["ca_certs"] = (os.path.dirname(__file__) + 
-                                               '/ca-certificates.crt')
+                    ssl_options["ca_certs"] = _DEFAULT_CA_CERTS
                 self.stream = SSLIOStream(socket.socket(),
                                           io_loop=self.io_loop,
                                           ssl_options=ssl_options)
index 3dd08bd21a472cafdc9e84139a4eb217f8db53a1..ab797c4354149f219427b55e1271d3514946e358 100644 (file)
@@ -9,7 +9,7 @@ import socket
 
 from contextlib import closing
 from tornado.ioloop import IOLoop
-from tornado.simple_httpclient import SimpleAsyncHTTPClient
+from tornado.simple_httpclient import SimpleAsyncHTTPClient, _DEFAULT_CA_CERTS
 from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase, get_unused_port
 from tornado.web import Application, RequestHandler, asynchronous, url
 
@@ -206,3 +206,6 @@ class SimpleHTTPClientTestCase(AsyncHTTPTestCase, LogTrapTestCase):
         self.assertTrue(response.effective_url.endswith("/countdown/2"))
         self.assertTrue(response.headers["Location"].endswith("/countdown/1"))
 
+    def test_default_certificates_exist(self):
+        open(_DEFAULT_CA_CERTS)
+