crowdsec/docker/test/tests/test_hub.py
mmetc 301782ae18
Docker tests: use pytest-cs 0.2 (#2079)
* 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
2023-02-28 17:49:32 +01:00

28 lines
881 B
Python

#!/usr/bin/env python
"""
Test pre-installed hub items.
"""
from http import HTTPStatus
import json
import pytest
pytestmark = pytest.mark.docker
def test_preinstalled_hub(crowdsec, flavor):
"""Test hub objects installed in the entrypoint"""
with crowdsec(flavor=flavor) as cs:
cs.wait_for_log("*Starting processing data*")
cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
res = cs.cont.exec_run('cscli hub list -o json')
assert res.exit_code == 0
j = json.loads(res.output)
collections = {c['name']: c for c in j['collections']}
assert collections['crowdsecurity/linux']['status'] == 'enabled'
parsers = {c['name']: c for c in j['parsers']}
assert parsers['crowdsecurity/whitelists']['status'] == 'enabled'
assert parsers['crowdsecurity/docker-logs']['status'] == 'enabled'