github.com/crowdsecurity/crowdsec@v1.6.1/docker/test/tests/test_flavors.py (about) 1 #!/usr/bin/env python 2 3 """ 4 Test basic behavior of all the image variants 5 """ 6 7 from http import HTTPStatus 8 9 import pytest 10 11 pytestmark = pytest.mark.docker 12 13 14 def test_cscli_lapi(crowdsec, flavor): 15 """Test if cscli can talk to lapi""" 16 with crowdsec(flavor=flavor) as cs: 17 cs.wait_for_log("*Starting processing data*") 18 cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK) 19 x = cs.cont.exec_run('cscli lapi status') 20 assert x.exit_code == 0 21 stdout = x.output.decode() 22 assert "You can successfully interact with Local API (LAPI)" in stdout 23 24 25 @pytest.mark.skip(reason="currently broken by hub upgrade") 26 def test_flavor_content(crowdsec, flavor): 27 """Test flavor contents""" 28 with crowdsec(flavor=flavor) as cs: 29 cs.wait_for_log("*Starting processing data*") 30 cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK) 31 x = cs.cont.exec_run('ls -1 /var/lib/crowdsec/data/') 32 assert x.exit_code == 0 33 stdout = x.output.decode() 34 if 'slim' in flavor or 'plugins' in flavor: 35 assert 'GeoLite2-City.mmdb' not in stdout 36 assert 'GeoLite2-ASN.mmdb' not in stdout 37 else: 38 assert 'GeoLite2-City.mmdb' in stdout 39 assert 'GeoLite2-ASN.mmdb' in stdout 40 assert 'crowdsec.db' in stdout 41 42 x = cs.cont.exec_run( 43 'ls -1 /usr/local/lib/crowdsec/plugins/') 44 stdout = x.output.decode() 45 if 'slim' in flavor: 46 # the exact return code and full message depend 47 # on the 'ls' implementation (busybox vs coreutils) 48 assert x.exit_code != 0 49 assert 'No such file or directory' in stdout 50 assert 'notification-email' not in stdout 51 assert 'notification-http' not in stdout 52 assert 'notification-slack' not in stdout 53 assert 'notification-splunk' not in stdout 54 assert 'notification-sentinel' not in stdout 55 else: 56 assert x.exit_code == 0 57 assert 'notification-email' in stdout 58 assert 'notification-http' in stdout 59 assert 'notification-slack' in stdout 60 assert 'notification-splunk' in stdout 61 assert 'notification-sentinel' in stdout