(self)
| 2421 | await con.close() |
| 2422 | |
| 2423 | async def test_direct_tls_connection(self): |
| 2424 | # A TLS-terminating gateway also supports PostgreSQL versions predating |
| 2425 | # direct TLS. Every accepted connection must execute a real query. |
| 2426 | self._allow_plaintext() |
| 2427 | ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 2428 | ctx.check_hostname = False |
| 2429 | ctx.verify_mode = ssl.CERT_NONE |
| 2430 | for mode in ('require', 'verify-ca', 'verify-full', True, ctx): |
| 2431 | with self.subTest(mode=mode): |
| 2432 | async with self.connection_proxy(direct=True) as (port, seen): |
| 2433 | with unittest.mock.patch.dict(os.environ, { |
| 2434 | 'SSL_CERT_FILE': SSL_CA_CERT_FILE, |
| 2435 | }): |
| 2436 | await self._test_works( |
| 2437 | dsn='postgresql://ssl_user@localhost/postgres' |
| 2438 | '?sslrootcert=' + SSL_CA_CERT_FILE, |
| 2439 | port=port, ssl=mode, direct_tls=True, |
| 2440 | expected_ssl=True) |
| 2441 | self.assertEqual(seen, [True]) |
| 2442 | self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) |
| 2443 | self.assertFalse(ctx.check_hostname) |
| 2444 | |
| 2445 | async def test_direct_tls_native(self): |
| 2446 | if self.cluster.get_pg_version() < (17, 0): |
nothing calls this directly
no test coverage detected