mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-14 05:14:06 +02:00
* tests: don't run crowdsec if not necessary * make listen_uri report the random port number when 0 is requested * move apiserver.getTLSAuthType() -> csconfig.TLSCfg.GetAuthType() * move apiserver.isEnrolled() -> apiclient.ApiClient.IsEnrolled() * extract function apiserver.recoverFromPanic() * simplify and move APIServer.GetTLSConfig() -> TLSCfg.GetTLSConfig() * moved TLSCfg type to csconfig/tls.go * APIServer.InitController(): early return / happy path * extract function apiserver.newGinLogger() * lapi tests * update unit test * lint (testify) * lint (whitespace, variable names) * update docker tests
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
|
|
from http import HTTPStatus
|
|
import random
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.docker
|
|
|
|
|
|
def test_split_lapi_agent(crowdsec, flavor):
|
|
rand = str(random.randint(0, 10000))
|
|
lapiname = f'lapi-{rand}'
|
|
agentname = f'agent-{rand}'
|
|
|
|
lapi_env = {
|
|
'AGENT_USERNAME': 'testagent',
|
|
'AGENT_PASSWORD': 'testpassword',
|
|
}
|
|
|
|
agent_env = {
|
|
'AGENT_USERNAME': 'testagent',
|
|
'AGENT_PASSWORD': 'testpassword',
|
|
'DISABLE_LOCAL_API': 'true',
|
|
'LOCAL_API_URL': f'http://{lapiname}:8080',
|
|
}
|
|
|
|
cs_lapi = crowdsec(name=lapiname, environment=lapi_env, flavor=flavor)
|
|
cs_agent = crowdsec(name=agentname, environment=agent_env, flavor=flavor)
|
|
|
|
with cs_lapi as lapi:
|
|
lapi.wait_for_log("*CrowdSec Local API listening on *:8080*")
|
|
lapi.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
|
|
with cs_agent as agent:
|
|
agent.wait_for_log("*Starting processing data*")
|
|
res = agent.cont.exec_run('cscli lapi status')
|
|
assert res.exit_code == 0
|
|
stdout = res.output.decode()
|
|
assert "You can successfully interact with Local API (LAPI)" in stdout
|