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

Method test_local_good_hostname

Lib/test/test_httplib.py:2157–2168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2155 self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED')
2156
2157 def test_local_good_hostname(self):
2158 # The (valid) cert validates the HTTPS hostname
2159 import ssl
2160 server = self.make_server(CERT_localhost)
2161 context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2162 context.load_verify_locations(CERT_localhost)
2163 h = client.HTTPSConnection('localhost', server.port, context=context)
2164 self.addCleanup(h.close)
2165 h.request('GET', '/nonexistent')
2166 resp = h.getresponse()
2167 self.addCleanup(resp.close)
2168 self.assertEqual(resp.status, 404)
2169
2170 def test_local_bad_hostname(self):
2171 # The (valid) cert doesn't validate the HTTPS hostname

Callers

nothing calls this directly

Calls 5

make_serverMethod · 0.95
addCleanupMethod · 0.80
requestMethod · 0.45
getresponseMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected