| 1895 | await con.close() |
| 1896 | |
| 1897 | async def verify_fails(sslmode, *, host='localhost', exn_type): |
| 1898 | # XXX: uvloop artifact |
| 1899 | old_handler = self.loop.get_exception_handler() |
| 1900 | con = None |
| 1901 | try: |
| 1902 | self.loop.set_exception_handler(lambda *args: None) |
| 1903 | with self.assertRaises(exn_type): |
| 1904 | con = await self.connect( |
| 1905 | dsn='postgresql://foo/?sslmode=' + sslmode, |
| 1906 | host=host, |
| 1907 | user='ssl_user') |
| 1908 | await con.fetchval('SELECT 42') |
| 1909 | finally: |
| 1910 | if con: |
| 1911 | await con.close() |
| 1912 | self.loop.set_exception_handler(old_handler) |
| 1913 | |
| 1914 | invalid_auth_err = asyncpg.InvalidAuthorizationSpecificationError |
| 1915 | await verify_fails('disable', exn_type=invalid_auth_err) |