|
4 | 4 | Test agent-lapi and cscli-lapi communication via TLS, on the same container.
|
5 | 5 | """
|
6 | 6 |
|
7 |
| -import random |
| 7 | +import uuid |
8 | 8 |
|
9 | 9 | from pytest_cs import Status
|
10 | 10 |
|
@@ -140,7 +140,7 @@ def test_tls_lapi_var(crowdsec, flavor, certs_dir):
|
140 | 140 | def test_tls_split_lapi_agent(crowdsec, flavor, certs_dir):
|
141 | 141 | """Server-only certificate, split containers"""
|
142 | 142 |
|
143 |
| - rand = random.randint(0, 10000) |
| 143 | + rand = uuid.uuid1() |
144 | 144 | lapiname = 'lapi-' + str(rand)
|
145 | 145 | agentname = 'agent-' + str(rand)
|
146 | 146 |
|
@@ -193,7 +193,7 @@ def test_tls_split_lapi_agent(crowdsec, flavor, certs_dir):
|
193 | 193 | def test_tls_mutual_split_lapi_agent(crowdsec, flavor, certs_dir):
|
194 | 194 | """Server and client certificates, split containers"""
|
195 | 195 |
|
196 |
| - rand = random.randint(0, 10000) |
| 196 | + rand = uuid.uuid1() |
197 | 197 | lapiname = 'lapi-' + str(rand)
|
198 | 198 | agentname = 'agent-' + str(rand)
|
199 | 199 |
|
@@ -244,7 +244,7 @@ def test_tls_mutual_split_lapi_agent(crowdsec, flavor, certs_dir):
|
244 | 244 | def test_tls_client_ou(crowdsec, certs_dir):
|
245 | 245 | """Check behavior of client certificate vs AGENTS_ALLOWED_OU"""
|
246 | 246 |
|
247 |
| - rand = random.randint(0, 10000) |
| 247 | + rand = uuid.uuid1() |
248 | 248 | lapiname = 'lapi-' + str(rand)
|
249 | 249 | agentname = 'agent-' + str(rand)
|
250 | 250 |
|
@@ -287,6 +287,19 @@ def test_tls_client_ou(crowdsec, certs_dir):
|
287 | 287 |
|
288 | 288 | lapi_env['AGENTS_ALLOWED_OU'] = 'custom-client-ou'
|
289 | 289 |
|
| 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 | + |
290 | 303 | cs_lapi = crowdsec(name=lapiname, environment=lapi_env, volumes=volumes)
|
291 | 304 | cs_agent = crowdsec(name=agentname, environment=agent_env, volumes=volumes)
|
292 | 305 |
|
|
0 commit comments