blob: 49c5b2736b965cdbab48378c83d44f25befba87a [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@intel.com>
3
4From cabe916dc694997d4892b58986e73a713d5a2f8d Mon Sep 17 00:00:00 2001
5From: "Miss Islington (bot)"
6 <31488909+miss-islington@users.noreply.github.com>
7Date: Thu, 16 Aug 2018 15:38:03 -0400
8Subject: [PATCH] [3.6] bpo-34391: Fix ftplib test for TLS 1.3 (GH-8787)
9 (#8790)
10
11Read from data socket to avoid "[SSL] shutdown while in init" exception
12during shutdown of the dummy server.
13
14Signed-off-by: Christian Heimes <christian@python.org>
15
16
17<!-- issue-number: [bpo-34391](https://www.bugs.python.org/issue34391) -->
18https://bugs.python.org/issue34391
19<!-- /issue-number -->
20(cherry picked from commit 1590c393360df059160145e7475754427bfc6680)
21
22
23Co-authored-by: Christian Heimes <christian@python.org>
24---
25 Lib/test/test_ftplib.py | 5 +++++
26 Misc/NEWS.d/next/Tests/2018-08-16-18-48-47.bpo-34391.ouNfxC.rst | 1 +
27 2 files changed, 6 insertions(+)
28 create mode 100644 Misc/NEWS.d/next/Tests/2018-08-16-18-48-47.bpo-34391.ouNfxC.rst
29
30diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
31index 44dd73aeca..4ff2f71afb 100644
32--- a/Lib/test/test_ftplib.py
33+++ b/Lib/test/test_ftplib.py
34@@ -876,18 +876,23 @@ class TestTLS_FTPClass(TestCase):
35 # clear text
36 with self.client.transfercmd('list') as sock:
37 self.assertNotIsInstance(sock, ssl.SSLSocket)
38+ self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
39 self.assertEqual(self.client.voidresp(), "226 transfer complete")
40
41 # secured, after PROT P
42 self.client.prot_p()
43 with self.client.transfercmd('list') as sock:
44 self.assertIsInstance(sock, ssl.SSLSocket)
45+ # consume from SSL socket to finalize handshake and avoid
46+ # "SSLError [SSL] shutdown while in init"
47+ self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
48 self.assertEqual(self.client.voidresp(), "226 transfer complete")
49
50 # PROT C is issued, the connection must be in cleartext again
51 self.client.prot_c()
52 with self.client.transfercmd('list') as sock:
53 self.assertNotIsInstance(sock, ssl.SSLSocket)
54+ self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
55 self.assertEqual(self.client.voidresp(), "226 transfer complete")
56
57 def test_login(self):
58--
592.11.0
60