(self)
| 360 | self.assertEqual(cons, ['error', con._con]) |
| 361 | |
| 362 | async def test_pool_auth(self): |
| 363 | if not self.cluster.is_managed(): |
| 364 | self.skipTest('unmanaged cluster') |
| 365 | |
| 366 | self.cluster.reset_hba() |
| 367 | |
| 368 | if _system != 'Windows': |
| 369 | self.cluster.add_hba_entry( |
| 370 | type='local', |
| 371 | database='postgres', user='pooluser', |
| 372 | auth_method='md5') |
| 373 | |
| 374 | self.cluster.add_hba_entry( |
| 375 | type='host', address='127.0.0.1/32', |
| 376 | database='postgres', user='pooluser', |
| 377 | auth_method='md5') |
| 378 | |
| 379 | self.cluster.add_hba_entry( |
| 380 | type='host', address='::1/128', |
| 381 | database='postgres', user='pooluser', |
| 382 | auth_method='md5') |
| 383 | |
| 384 | self.cluster.reload() |
| 385 | |
| 386 | try: |
| 387 | await self.con.execute(''' |
| 388 | CREATE ROLE pooluser WITH LOGIN PASSWORD 'poolpassword' |
| 389 | ''') |
| 390 | |
| 391 | pool = await self.create_pool(database='postgres', |
| 392 | user='pooluser', |
| 393 | password='poolpassword', |
| 394 | min_size=5, max_size=10) |
| 395 | |
| 396 | async def worker(): |
| 397 | con = await pool.acquire() |
| 398 | self.assertEqual(await con.fetchval('SELECT 1'), 1) |
| 399 | await pool.release(con) |
| 400 | |
| 401 | tasks = [worker() for _ in range(5)] |
| 402 | await asyncio.gather(*tasks) |
| 403 | await pool.close() |
| 404 | |
| 405 | finally: |
| 406 | await self.con.execute('DROP ROLE pooluser') |
| 407 | |
| 408 | # Reset cluster's pg_hba.conf since we've meddled with it |
| 409 | self.cluster.trust_local_connections() |
| 410 | self.cluster.reload() |
| 411 | |
| 412 | async def test_pool_handles_task_cancel_in_acquire_with_timeout(self): |
| 413 | # See https://github.com/MagicStack/asyncpg/issues/547 |
nothing calls this directly
no test coverage detected