github.com/crowdsecurity/crowdsec@v1.6.1/docker/test/tests/test_agent_only.py (about) 1 #!/usr/bin/env python 2 3 from http import HTTPStatus 4 import random 5 6 import pytest 7 8 pytestmark = pytest.mark.docker 9 10 11 def test_split_lapi_agent(crowdsec, flavor): 12 rand = str(random.randint(0, 10000)) 13 lapiname = f'lapi-{rand}' 14 agentname = f'agent-{rand}' 15 16 lapi_env = { 17 'AGENT_USERNAME': 'testagent', 18 'AGENT_PASSWORD': 'testpassword', 19 } 20 21 agent_env = { 22 'AGENT_USERNAME': 'testagent', 23 'AGENT_PASSWORD': 'testpassword', 24 'DISABLE_LOCAL_API': 'true', 25 'LOCAL_API_URL': f'http://{lapiname}:8080', 26 } 27 28 cs_lapi = crowdsec(name=lapiname, environment=lapi_env, flavor=flavor) 29 cs_agent = crowdsec(name=agentname, environment=agent_env, flavor=flavor) 30 31 with cs_lapi as lapi: 32 lapi.wait_for_log("*CrowdSec Local API listening on *:8080*") 33 lapi.wait_for_http(8080, '/health', want_status=HTTPStatus.OK) 34 with cs_agent as agent: 35 agent.wait_for_log("*Starting processing data*") 36 res = agent.cont.exec_run('cscli lapi status') 37 assert res.exit_code == 0 38 stdout = res.output.decode() 39 assert "You can successfully interact with Local API (LAPI)" in stdout