mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
ca4220be1f
commit
da23259f99
6 changed files with 36 additions and 30 deletions
|
@ -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_sni(self):
|
||||
self.skipTest("test disabled - test server needed")
|
||||
# Checks that Server Name Indication works, if supported by the
|
||||
# OpenSSL linked to.
|
||||
# The ssl module itself doesn't have server-side support for SNI,
|
||||
# so we rely on a third-party test site.
|
||||
expect_sni = ssl.HAS_SNI
|
||||
with support.transient_internet("XXX"):
|
||||
u = urllib.request.urlopen("XXX")
|
||||
contents = u.readall()
|
||||
if expect_sni:
|
||||
self.assertIn(b"Great", contents)
|
||||
self.assertNotIn(b"Unfortunately", contents)
|
||||
else:
|
||||
self.assertNotIn(b"Great", contents)
|
||||
self.assertIn(b"Unfortunately", contents)
|
||||
|
||||
|
||||
def test_main():
|
||||
support.requires("network")
|
||||
support.run_unittest(AuthTests,
|
||||
HTTPSTests,
|
||||
OtherNetworkTests,
|
||||
CloseSocketTest,
|
||||
TimeoutTest,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue