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

Method test_check_hostname

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

Source from the content-addressed store, hash-verified

1014
1015 @skipUnless(False, "FIXME: bpo-32706")
1016 def test_check_hostname(self):
1017 self.client.quit()
1018 ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
1019 self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
1020 self.assertEqual(ctx.check_hostname, True)
1021 ctx.load_verify_locations(CAFILE)
1022 self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)
1023
1024 # 127.0.0.1 doesn't match SAN
1025 self.client.connect(self.server.host, self.server.port)
1026 with self.assertRaises(ssl.CertificateError):
1027 self.client.auth()
1028 # exception quits connection
1029
1030 self.client.connect(self.server.host, self.server.port)
1031 self.client.prot_p()
1032 with self.assertRaises(ssl.CertificateError):
1033 with self.client.transfercmd("list") as sock:
1034 pass
1035 self.client.quit()
1036
1037 self.client.connect("localhost", self.server.port)
1038 self.client.auth()
1039 self.client.quit()
1040
1041 self.client.connect("localhost", self.server.port)
1042 self.client.prot_p()
1043 with self.client.transfercmd("list") as sock:
1044 pass
1045
1046
1047class TestTimeouts(TestCase):

Callers

nothing calls this directly

Calls 7

prot_pMethod · 0.80
transfercmdMethod · 0.80
quitMethod · 0.45
assertEqualMethod · 0.45
connectMethod · 0.45
assertRaisesMethod · 0.45
authMethod · 0.45

Tested by

no test coverage detected