Skip to content

Commit 6b9e065

Browse files
authored
CI: update pytest-cs - don't remove stopped containers after tests (#2459)
1 parent d45bec4 commit 6b9e065

File tree

3 files changed

+50
-27
lines changed

3 files changed

+50
-27
lines changed

docker/test/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[packages]
22
pytest-dotenv = "0.5.2"
33
pytest-xdist = "3.3.1"
4-
pytest-cs = {ref = "0.7.17", git = "https://github.com/crowdsecurity/pytest-cs.git"}
4+
pytest-cs = {ref = "0.7.18", git = "https://github.com/crowdsecurity/pytest-cs.git"}
55

66
[dev-packages]
77
gnureadline = "8.1.2"

docker/test/Pipfile.lock

Lines changed: 32 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/test/tests/test_tls.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Test agent-lapi and cscli-lapi communication via TLS, on the same container.
55
"""
66

7-
import random
7+
import uuid
88

99
from pytest_cs import Status
1010

@@ -140,7 +140,7 @@ def test_tls_lapi_var(crowdsec, flavor, certs_dir):
140140
def test_tls_split_lapi_agent(crowdsec, flavor, certs_dir):
141141
"""Server-only certificate, split containers"""
142142

143-
rand = random.randint(0, 10000)
143+
rand = uuid.uuid1()
144144
lapiname = 'lapi-' + str(rand)
145145
agentname = 'agent-' + str(rand)
146146

@@ -193,7 +193,7 @@ def test_tls_split_lapi_agent(crowdsec, flavor, certs_dir):
193193
def test_tls_mutual_split_lapi_agent(crowdsec, flavor, certs_dir):
194194
"""Server and client certificates, split containers"""
195195

196-
rand = random.randint(0, 10000)
196+
rand = uuid.uuid1()
197197
lapiname = 'lapi-' + str(rand)
198198
agentname = 'agent-' + str(rand)
199199

@@ -244,7 +244,7 @@ def test_tls_mutual_split_lapi_agent(crowdsec, flavor, certs_dir):
244244
def test_tls_client_ou(crowdsec, certs_dir):
245245
"""Check behavior of client certificate vs AGENTS_ALLOWED_OU"""
246246

247-
rand = random.randint(0, 10000)
247+
rand = uuid.uuid1()
248248
lapiname = 'lapi-' + str(rand)
249249
agentname = 'agent-' + str(rand)
250250

@@ -287,6 +287,19 @@ def test_tls_client_ou(crowdsec, certs_dir):
287287

288288
lapi_env['AGENTS_ALLOWED_OU'] = 'custom-client-ou'
289289

290+
# change container names to avoid conflict
291+
# recreate certificates because they need the new hostname
292+
293+
rand = uuid.uuid1()
294+
lapiname = 'lapi-' + str(rand)
295+
agentname = 'agent-' + str(rand)
296+
297+
agent_env['LOCAL_API_URL'] = f'https://{lapiname}:8080'
298+
299+
volumes = {
300+
certs_dir(lapi_hostname=lapiname, agent_ou='custom-client-ou'): {'bind': '/etc/ssl/crowdsec', 'mode': 'ro'},
301+
}
302+
290303
cs_lapi = crowdsec(name=lapiname, environment=lapi_env, volumes=volumes)
291304
cs_agent = crowdsec(name=agentname, environment=agent_env, volumes=volumes)
292305

0 commit comments

Comments
 (0)