cpython: f74a12e23aaa (original) (raw)

Mercurial > cpython

changeset 82026:f74a12e23aaa

Issue #17107: Test client-side SNI support in urllib.request thanks to the new server-side SNI support in the ssl module. Initial patch by Daniel Black. [#17107]

Antoine Pitrou solipsis@pitrou.net
date Tue, 05 Feb 2013 21:20:51 +0100
parents 2a369c32f1f1
children 5f8c68281d18
files Lib/test/ssl_servers.py Lib/test/test_httplib.py Lib/test/test_ssl.py Lib/test/test_urllib2_localnet.py Lib/test/test_urllib2net.py Misc/NEWS
diffstat 6 files changed, 36 insertions(+), 30 deletions(-)[+] [-] Lib/test/ssl_servers.py 8 Lib/test/test_httplib.py 2 Lib/test/test_ssl.py 2 Lib/test/test_urllib2_localnet.py 28 Lib/test/test_urllib2net.py 22 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/test/ssl_servers.py +++ b/Lib/test/ssl_servers.py @@ -147,9 +147,11 @@ class HTTPSServerThread(threading.Thread self.server.shutdown() -def make_https_server(case, certfile=CERTFILE, host=HOST, handler_class=None):

+def make_https_server(case, *, context=None, certfile=CERTFILE,

--- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -703,7 +703,7 @@ class HTTPSTest(TestCase): def make_server(self, certfile): from test.ssl_servers import make_https_server

def test_attributes(self): # simple test to check it's storing the timeout

--- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1637,7 +1637,7 @@ else: def test_socketserver(self): """Using a SocketServer to create and manage SSL connections."""

--- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -9,7 +9,10 @@ import unittest import hashlib from test import support threading = support.import_module('threading') - +try:

+except ImportError:

here = os.path.dirname(file)

Self-signed cert file for 'localhost'

@@ -17,6 +20,7 @@ CERT_localhost = os.path.join(here, 'key

Self-signed cert file for 'fakehostname'

CERT_fakehostname = os.path.join(here, 'keycert2.pem') +

Loopback http server infrastructure

class LoopbackHttpServer(http.server.HTTPServer): @@ -353,12 +357,15 @@ class TestUrlopen(unittest.TestCase): def setUp(self): super(TestUrlopen, self).setUp() # Ignore proxies for localhost tests.

def tearDown(self): if self.server is not None: self.server.stop()

def urlopen(self, url, data=None, **kwargs): @@ -386,14 +393,14 @@ class TestUrlopen(unittest.TestCase): handler.port = port return handler

@@ -483,6 +490,21 @@ class TestUrlopen(unittest.TestCase): self.urlopen("https://localhost:%s/bizarre" % handler.port, cadefault=True)

+ def test_sending_headers(self): handler = self.start_server() req = urllib.request.Request("http://localhost:%s/" % handler.port,

--- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -330,31 +330,9 @@ class TimeoutTest(unittest.TestCase): self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60) -@unittest.skipUnless(ssl, "requires SSL support") -class HTTPSTests(unittest.TestCase): -

- - def test_main(): support.requires("network") support.run_unittest(AuthTests,

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -754,6 +754,10 @@ Extension Modules Tests ----- +- Issue #17107: Test client-side SNI support in urllib.request thanks to