async def api_client(aiohttp_client, coresys: CoreSys): """Fixture for RestAPI client.""" api = RestAPI(coresys) api.webapp = web.Application() api.start = AsyncMock() await api.load() yield await aiohttp_client(api.webapp)
async def api_system(aiohttp_client, run_dir, coresys: CoreSys): """Fixture for RestAPI client.""" api = RestAPI(coresys) api.webapp = web.Application() await api.load() api.webapp.middlewares.append(api.security.system_validation) yield await aiohttp_client(api.webapp)
async def api_client(aiohttp_client, coresys: CoreSys): """Fixture for RestAPI client.""" @web.middleware async def _security_middleware(request: web.Request, handler: web.RequestHandler): """Make request are from Core.""" request[REQUEST_FROM] = coresys.homeassistant return await handler(request) api = RestAPI(coresys) api.webapp = web.Application(middlewares=[_security_middleware]) api.start = AsyncMock() await api.load() yield await aiohttp_client(api.webapp)