MCPcopy
hub / github.com/aio-libs/aiohttp / test_uvloop_secure_https_proxy

Function test_uvloop_secure_https_proxy

tests/test_proxy_functional.py:234–265  ·  view source on GitHub ↗

Ensure HTTPS sites are accessible through a secure proxy without warning when using uvloop.

(
    client_ssl_ctx: ssl.SSLContext,
    ssl_ctx: ssl.SSLContext,
    secure_proxy_url: URL,
    uvloop_loop: asyncio.AbstractEventLoop,
)

Source from the content-addressed store, hash-verified

232# https://github.com/abhinavsingh/proxy.py/blob/30574fd0414005dfa8792a6e797023e862bdcf43/proxy/common/utils.py#L226
233# otherwise this test will fail because the proxy will die with an error.
234async def test_uvloop_secure_https_proxy(
235 client_ssl_ctx: ssl.SSLContext,
236 ssl_ctx: ssl.SSLContext,
237 secure_proxy_url: URL,
238 uvloop_loop: asyncio.AbstractEventLoop,
239) -> None:
240 """Ensure HTTPS sites are accessible through a secure proxy without warning when using uvloop."""
241 payload = str(uuid4())
242
243 async def handler(request: web.Request) -> web.Response:
244 return web.Response(text=payload)
245
246 app = web.Application()
247 app.router.add_route("GET", "/", handler)
248 server = TestServer(app, host="127.0.0.1")
249 await server.start_server(ssl=ssl_ctx)
250
251 url = URL.build(scheme="https", host=server.host, port=server.port)
252 conn = aiohttp.TCPConnector(force_close=True)
253 sess = aiohttp.ClientSession(connector=conn)
254 try:
255 async with sess.get(
256 url, proxy=secure_proxy_url, ssl=client_ssl_ctx
257 ) as response:
258 assert response.status == 200
259 assert await response.text() == payload
260 finally:
261 await sess.close()
262 await conn.close()
263 await server.close()
264 await asyncio.sleep(0)
265 await asyncio.sleep(0.1)
266
267
268@pytest.fixture

Callers

nothing calls this directly

Calls 8

getMethod · 0.95
closeMethod · 0.95
closeMethod · 0.95
TestServerClass · 0.90
add_routeMethod · 0.45
start_serverMethod · 0.45
textMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…