diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-07-20 17:35:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-07-20 17:35:16 (GMT) |
commit | 60a26e05162c5b6d3d67fa53bb2057b017f932b1 (patch) | |
tree | 76952e87739d7bb479f1302a02c9040ef22c474b /Lib/test/test_ssl.py | |
parent | 60d634ae4a89854b4e7468445eeafa556a7979c9 (diff) | |
download | cpython-60a26e05162c5b6d3d67fa53bb2057b017f932b1.zip cpython-60a26e05162c5b6d3d67fa53bb2057b017f932b1.tar.gz cpython-60a26e05162c5b6d3d67fa53bb2057b017f932b1.tar.bz2 |
Issue #9177: Calling read() or write() now raises ValueError, not AttributeError, on a closed SSL socket.
Patch by Senko Rasic.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 210040b..6998dda 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2311,6 +2311,21 @@ else: self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_INTERNAL_ERROR') self.assertIn("TypeError", stderr.getvalue()) + def test_read_write_after_close_raises_valuerror(self): + context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) + context.verify_mode = ssl.CERT_REQUIRED + context.load_verify_locations(CERTFILE) + context.load_cert_chain(CERTFILE) + server = ThreadedEchoServer(context=context, chatty=False) + + with server: + s = context.wrap_socket(socket.socket()) + s.connect((HOST, server.port)) + s.close() + + self.assertRaises(ValueError, s.read, 1024) + self.assertRaises(ValueError, s.write, 'hello') + def test_main(verbose=False): if support.verbose: |