MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_ssl_startup_retry_boundary

Method test_ssl_startup_retry_boundary

tests/test_connect.py:2209–2242  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2207 self.cluster.reload()
2208
2209 async def test_ssl_startup_retry_boundary(self):
2210 self._allow_plaintext()
2211 cases = itertools.product(
2212 ('allow', 'prefer'),
2213 (False, True),
2214 (asyncpg.InvalidAuthorizationSpecificationError,
2215 asyncpg.InvalidCatalogNameError,
2216 asyncpg.TooManyConnectionsError,
2217 asyncpg.ConnectionDoesNotExistError),
2218 )
2219 for mode, auth_ok, error in cases:
2220 with self.subTest(mode=mode, auth_ok=auth_ok, error=error):
2221 fault = {'auth_ok': auth_ok, 'error': error}
2222 async with self.connection_proxy(fault) as result:
2223 port, seen = result
2224 calls = []
2225
2226 async def password():
2227 calls.append(True)
2228 return 'unused with trust authentication'
2229
2230 options = dict(host='127.0.0.1', port=port,
2231 user='ssl_user', ssl=mode,
2232 password=password)
2233 if auth_ok:
2234 with self.assertRaises(error):
2235 await self.connect(**options)
2236 self.assertEqual(seen, [mode == 'prefer'])
2237 else:
2238 await self._test_works(
2239 expected_ssl=mode == 'allow', **options)
2240 self.assertEqual(
2241 seen, [mode == 'prefer', mode == 'allow'])
2242 self.assertEqual(len(calls), 1)
2243
2244 async def test_ssl_post_authentication_server_error(self):
2245 # PostgreSQL processes startup GUCs after AuthenticationOk.

Callers

nothing calls this directly

Calls 4

_allow_plaintextMethod · 0.95
connection_proxyMethod · 0.80
_test_worksMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected