From: Ben Darnell Date: Sun, 20 Feb 2011 20:33:00 +0000 (-0800) Subject: Check that the default certificates file exists in a unit test. X-Git-Tag: v1.2.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8b6d985f11e104e4f6f4e111578bac833f281fe;p=thirdparty%2Ftornado.git Check that the default certificates file exists in a unit test. --- diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index d6be72fc6..3a7884ef2 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -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) diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 3dd08bd21..ab797c435 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -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) +