cscli: improved hub management (#3352)

This commit is contained in:
mmetc 2024-12-26 15:21:52 +01:00 committed by GitHub
parent 466f39b880
commit a1d26bdc5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 3138 additions and 2672 deletions

View file

@ -17,7 +17,7 @@ def test_preinstalled_hub(crowdsec, flavor):
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')
res = cs.cont.exec_run('cscli hub list -o json', stderr=False)
assert res.exit_code == 0
j = json.loads(res.output)
collections = {c['name']: c for c in j['collections']}

View file

@ -28,10 +28,8 @@ def test_install_two_collections(crowdsec, flavor):
assert items[it1]['status'] == 'enabled'
assert items[it2]['status'] == 'enabled'
cs.wait_for_log([
# f'*collections install "{it1}"*'
# f'*collections install "{it2}"*'
f'*Enabled collections: {it1}*',
f'*Enabled collections: {it2}*',
f'*enabling collections:{it1}*',
f'*enabling collections:{it2}*',
])
@ -50,8 +48,7 @@ def test_disable_collection(crowdsec, flavor):
items = {c['name'] for c in j['collections']}
assert it not in items
cs.wait_for_log([
# f'*collections remove "{it}*",
f'*Removed symlink [[]{it}[]]*',
f'*disabling collections:{it}*',
])
@ -72,7 +69,7 @@ def test_install_and_disable_collection(crowdsec, flavor):
assert it not in items
logs = cs.log_lines()
# check that there was no attempt to install
assert not any(f'Enabled collections: {it}' in line for line in logs)
assert not any(f'enabling collections:{it}' in line for line in logs)
# already done in bats, prividing here as example of a somewhat complex test
@ -91,7 +88,7 @@ def test_taint_bubble_up(crowdsec, tmp_path_factory, flavor):
# implicit check for tainted=False
assert items[coll]['status'] == 'enabled'
cs.wait_for_log([
f'*Enabled collections: {coll}*',
f'*enabling collections:{coll}*',
])
scenario = 'crowdsecurity/http-crawl-non_statics'