(self)
| 378 | self.assertEqual(cons, ['error', con._con]) |
| 379 | |
| 380 | async def test_pool_auth(self): |
| 381 | if not self.cluster.is_managed(): |
| 382 | self.skipTest('unmanaged cluster') |
| 383 | |
| 384 | self.cluster.reset_hba() |
| 385 | |
| 386 | if _system != 'Windows': |
| 387 | self.cluster.add_hba_entry( |
| 388 | type='local', |
| 389 | database='postgres', user='pooluser', |
| 390 | auth_method='md5') |
| 391 | |
| 392 | self.cluster.add_hba_entry( |
| 393 | type='host', address='127.0.0.1/32', |
| 394 | database='postgres', user='pooluser', |
| 395 | auth_method='md5') |
| 396 | |
| 397 | self.cluster.add_hba_entry( |
| 398 | type='host', address='::1/128', |
| 399 | database='postgres', user='pooluser', |
| 400 | auth_method='md5') |
| 401 | |
| 402 | self.cluster.reload() |
| 403 | |
| 404 | try: |
| 405 | await self.con.execute(''' |
| 406 | CREATE ROLE pooluser WITH LOGIN PASSWORD 'poolpassword' |
| 407 | ''') |
| 408 | |
| 409 | pool = await self.create_pool(database='postgres', |
| 410 | user='pooluser', |
| 411 | password='poolpassword', |
| 412 | init_size=5, min_size=1, max_size=10) |
| 413 | |
| 414 | async def worker(): |
| 415 | con = await pool.acquire() |
| 416 | self.assertEqual(await con.fetchval('SELECT 1'), 1) |
| 417 | await pool.release(con) |
| 418 | |
| 419 | tasks = [worker() for _ in range(5)] |
| 420 | await asyncio.gather(*tasks) |
| 421 | await pool.close() |
| 422 | |
| 423 | finally: |
| 424 | await self.con.execute('DROP ROLE pooluser') |
| 425 | |
| 426 | # Reset cluster's pg_hba.conf since we've meddled with it |
| 427 | self.cluster.trust_local_connections() |
| 428 | self.cluster.reload() |
| 429 | |
| 430 | async def test_pool_handles_task_cancel_in_acquire_with_timeout(self): |
| 431 | # See https://github.com/MagicStack/asyncpg/issues/547 |
nothing calls this directly
no test coverage detected