mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-14 21:33:54 +02:00
* Use pytest-cs 0.2 * fix pipenv cache key * Cache docker layers * Load build images from buildx to docker * CI: commit Pipfile.lock * Add full docker tag * Cache only amd64 docker layers * Cache layer mode=min
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
#!/usr/bin/env python
|
|
|
|
"""
|
|
Test basic behavior of all the image variants
|
|
"""
|
|
|
|
from http import HTTPStatus
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.docker
|
|
|
|
|
|
def test_cscli_lapi(crowdsec, flavor):
|
|
"""Test if cscli can talk to lapi"""
|
|
with crowdsec(flavor=flavor) as cs:
|
|
cs.wait_for_log("*Starting processing data*")
|
|
cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
|
|
x = cs.cont.exec_run('cscli lapi status')
|
|
assert x.exit_code == 0
|
|
stdout = x.output.decode()
|
|
assert "You can successfully interact with Local API (LAPI)" in stdout
|
|
|
|
|
|
def test_flavor_content(crowdsec, flavor):
|
|
"""Test flavor contents"""
|
|
with crowdsec(flavor=flavor) as cs:
|
|
cs.wait_for_log("*Starting processing data*")
|
|
cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
|
|
x = cs.cont.exec_run('ls -1 /var/lib/crowdsec/data/')
|
|
assert x.exit_code == 0
|
|
stdout = x.output.decode()
|
|
if 'slim' in flavor or 'plugins' in flavor:
|
|
assert 'GeoLite2-City.mmdb' not in stdout
|
|
assert 'GeoLite2-ASN.mmdb' not in stdout
|
|
else:
|
|
assert 'GeoLite2-City.mmdb' in stdout
|
|
assert 'GeoLite2-ASN.mmdb' in stdout
|
|
assert 'crowdsec.db' in stdout
|
|
|
|
x = cs.cont.exec_run(
|
|
'ls -1 /usr/local/lib/crowdsec/plugins/')
|
|
stdout = x.output.decode()
|
|
if 'slim' in flavor or 'geoip' in flavor:
|
|
# the exact return code and full message depend
|
|
# on the 'ls' implementation (busybox vs coreutils)
|
|
assert x.exit_code != 0
|
|
assert 'No such file or directory' in stdout
|
|
assert 'notification-email' not in stdout
|
|
assert 'notification-http' not in stdout
|
|
assert 'notification-slack' not in stdout
|
|
assert 'notification-splunk' not in stdout
|
|
else:
|
|
assert x.exit_code == 0
|
|
assert 'notification-email' in stdout
|
|
assert 'notification-http' in stdout
|
|
assert 'notification-slack' in stdout
|
|
assert 'notification-splunk' in stdout
|