async def test_not_found(self): async with rproxy( self, self.UPSTREAM_PATH, subdomain=self.PROXY_SUBDOMAIN, path=self.PROXY_PATH, ) as rctx, aiohttp.ClientSession() as session: url = "http://%s.%s:%d%s" % ( self.PROXY_SUBDOMAIN + ".not.found", self.TEST_ADDRESS, rctx.port, self.PROXY_PATH, ) LOGGER.debug("rproxy url: %s", url) async with session.get(url) as resp: self.assertEqual(resp.status, HTTPStatus.NOT_FOUND)
async def test_path_joined(self): async with rproxy( self, self.UPSTREAM_PATH, subdomain=self.PROXY_SUBDOMAIN, path=self.PROXY_PATH, ) as rctx, aiohttp.ClientSession() as session: url = "http://%s.%s:%d%s" % ( self.PROXY_SUBDOMAIN, self.TEST_ADDRESS, rctx.port, self.PROXY_PATH + "/test/joined", ) LOGGER.debug("rproxy url: %s", url) async with session.get(url) as resp: self.assertEqual(resp.status, HTTPStatus.OK) text = await resp.text() self.assertEqual(self.UPSTREAM_PATH + "/test/joined", text)
async def test_websocket(self): async with rproxy( self, self.UPSTREAM_PATH, subdomain=self.PROXY_SUBDOMAIN, path=self.PROXY_PATH, ) as rctx, aiohttp.ClientSession() as session: url = "http://%s.%s:%d%s" % ( self.PROXY_SUBDOMAIN, self.TEST_ADDRESS, rctx.port, self.PROXY_PATH, ) LOGGER.debug("rproxy url: %s", url) async with aiohttp.ClientSession() as client_session: async with client_session.ws_connect(url) as ws: await ws.send_str(self.UPSTREAM_PATH + "/test/joined") async for msg in ws: text = msg.data self.assertEqual(self.UPSTREAM_PATH + "/test/joined", text) await ws.close()