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

Method verify_fails

tests/test_connect.py:2177–2194  ·  view source on GitHub ↗
(sslmode, *, host='localhost')

Source from the content-addressed store, hash-verified

2175 await con.close()
2176
2177 async def verify_fails(sslmode, *, host='localhost'):
2178 # XXX: uvloop artifact
2179 old_handler = self.loop.get_exception_handler()
2180 con = None
2181 try:
2182 self.loop.set_exception_handler(lambda *args: None)
2183 with self.assertRaises(
2184 asyncpg.InvalidAuthorizationSpecificationError
2185 ):
2186 con = await self.connect(
2187 dsn='postgresql://foo/?sslmode=' + sslmode,
2188 host=host,
2189 user='ssl_user')
2190 await con.fetchval('SELECT 42')
2191 finally:
2192 if con:
2193 await con.close()
2194 self.loop.set_exception_handler(old_handler)
2195
2196 await verify_works('disable')
2197 await verify_works('allow')

Callers

nothing calls this directly

Calls 3

connectMethod · 0.45
fetchvalMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected