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

Method test_connect_with_context_fail

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

Source from the content-addressed store, hash-verified

2155 self.assertTrue(cert)
2156
2157 def test_connect_with_context_fail(self):
2158 # This should fail because we have no verification certs. Connection
2159 # failure crashes ThreadedEchoServer, so run this in an independent
2160 # test method.
2161 ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2162 s = ctx.wrap_socket(
2163 socket.socket(socket.AF_INET),
2164 server_hostname=SIGNED_CERTFILE_HOSTNAME
2165 )
2166 self.addCleanup(s.close)
2167 # Allow for flexible libssl error messages.
2168 regex = re.compile(r"""(
2169 certificate verify failed # OpenSSL
2170 |
2171 CERTIFICATE_VERIFY_FAILED # AWS-LC
2172 )""", re.X)
2173 self.assertRaisesRegex(ssl.SSLError, regex,
2174 s.connect, self.server_addr)
2175
2176 def test_connect_capath(self):
2177 # Verify server certificates using the `capath` argument

Callers

nothing calls this directly

Calls 5

wrap_socketMethod · 0.95
socketMethod · 0.80
addCleanupMethod · 0.80
assertRaisesRegexMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected