MCPcopy Index your code
hub / github.com/python/cpython / test_data_connection

Method test_data_connection

Lib/test/test_ftplib.py:946–970  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

944 self.assertIsInstance(self.client.sock, ssl.SSLSocket)
945
946 def test_data_connection(self):
947 # clear text
948 with self.client.transfercmd('list') as sock:
949 self.assertNotIsInstance(sock, ssl.SSLSocket)
950 self.assertEqual(sock.recv(1024),
951 LIST_DATA.encode(self.client.encoding))
952 self.assertEqual(self.client.voidresp(), "226 transfer complete")
953
954 # secured, after PROT P
955 self.client.prot_p()
956 with self.client.transfercmd('list') as sock:
957 self.assertIsInstance(sock, ssl.SSLSocket)
958 # consume from SSL socket to finalize handshake and avoid
959 # "SSLError [SSL] shutdown while in init"
960 self.assertEqual(sock.recv(1024),
961 LIST_DATA.encode(self.client.encoding))
962 self.assertEqual(self.client.voidresp(), "226 transfer complete")
963
964 # PROT C is issued, the connection must be in cleartext again
965 self.client.prot_c()
966 with self.client.transfercmd('list') as sock:
967 self.assertNotIsInstance(sock, ssl.SSLSocket)
968 self.assertEqual(sock.recv(1024),
969 LIST_DATA.encode(self.client.encoding))
970 self.assertEqual(self.client.voidresp(), "226 transfer complete")
971
972 def test_login(self):
973 # login() is supposed to implicitly secure the control connection

Callers

nothing calls this directly

Calls 9

transfercmdMethod · 0.80
assertNotIsInstanceMethod · 0.80
voidrespMethod · 0.80
prot_pMethod · 0.80
assertIsInstanceMethod · 0.80
prot_cMethod · 0.80
assertEqualMethod · 0.45
recvMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected