Debian Codegraph @

dirsrvtests/tests/suites/basic/haproxy_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2025 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8
9 import ldap
10 import logging
11 import pytest
12 from lib389._constants import DEFAULT_SUFFIX, PASSWORD
13 from test389.topologies import topology_st as topo
14 from lib389.idm.user import UserAccount, UserAccounts
15 from lib389.idm.account import Anonymous
16
17 log = logging.getLogger(__name__)
18 DN = "uid=common,ou=people," + DEFAULT_SUFFIX
19 HOME_DIR = '/home/common'
20
21 @pytest.fixture(scope="function")
22 def setup_test(topo, request):
23 """Setup test environment"""
24 log.info("Add nsslapd-haproxy-trusted-ip attribute")
25 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.0.1')
26 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.1')
27
28 log.info("Add a user")
29 users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
30 try:
31 users.create(properties={
32 'uid': 'common',
33 'cn': 'common',
34 'sn': 'common',
35 'uidNumber': '3000',
36 'gidNumber': '4000',
37 'homeDirectory': HOME_DIR,
38 'description': 'test haproxy with this user',
39 'userPassword': PASSWORD
40 })
41 except ldap.ALREADY_EXISTS:
42 log.info("User already exists")
43 pass
44
45
46 def test_haproxy_trust_ip_attribute(topo, setup_test):
47 """Test nsslapd-haproxy-trusted-ip attribute set and delete
48
49 :id: 8a0789a6-3ede-40e2-966c-9a2c87eaac05
50 :setup: Standalone instance with nsslapd-haproxy-trusted-ip attribute and a user
51 :steps:
52 1. Check that nsslapd-haproxy-trusted-ip attribute is present
53 2. Delete nsslapd-haproxy-trusted-ip attribute
54 3. Check that nsslapd-haproxy-trusted-ip attribute is not present
55 :expectedresults:
56 1. Success
57 2. Success
58 3. Success
59 """
60
61 log.info("Check that nsslapd-haproxy-trusted-ip attribute is present")
62 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.1')
63 # Check nsslapd-haproxy-trusted-ip attribute is present in schema
64 assert topo.standalone.schema.query_attributetype('nsslapd-haproxy-trusted-ip') is not None
65
66 log.info("Delete nsslapd-haproxy-trusted-ip attribute")
67 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
68
69 log.info("Check that nsslapd-haproxy-trusted-ip attribute is not present")
70 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.1')
71
72
73 def test_binds_with_haproxy_trust_ip_attribute(topo, setup_test):
74 """Test that non-proxy binds are not blocked when nsslapd-haproxy-trusted-ip attribute is set
75
76 :id: 14273c16-fed9-497e-8ebb-09e3dabc7914
77 :setup: Standalone instance with nsslapd-haproxy-trusted-ip attribute and a user
78 :steps:
79 1. Try to bind as anonymous user
80 2. Try to bind as a user
81 3. Check that userPassword is correct and we can get it
82 :expectedresults:
83 1. Success
84 2. Success
85 3. Success
86 """
87
88 log.info("Bind as anonymous user")
89 Anonymous(topo.standalone).bind()
90
91 log.info("Bind as a user")
92 user_entry = UserAccount(topo.standalone, DN)
93 user_conn = user_entry.bind(PASSWORD)
94
95 log.info("Check that userPassword is correct and we can get it")
96 user_entry = UserAccount(user_conn, DN)
97 home = user_entry.get_attr_val_utf8('homeDirectory')
98 assert home == HOME_DIR
99
100
101 def test_haproxy_trust_ip_subnet_ipv4(topo):
102 """Test nsslapd-haproxy-trusted-ip with IPv4 CIDR subnet notation
103
104 :id: 20023301-b7c7-4db5-8287-06f6bbb14786
105 :setup: Standalone instance
106 :steps:
107 1. Set nsslapd-haproxy-trusted-ip to an IPv4 subnet (192.168.0.0/24)
108 2. Check that the subnet is present
109 3. Delete the attribute
110 :expectedresults:
111 1. Success
112 2. Success
113 3. Success
114 """
115 log.info("Set nsslapd-haproxy-trusted-ip to IPv4 subnet")
116 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.0.0/24')
117
118 log.info("Check that nsslapd-haproxy-trusted-ip subnet is present")
119 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.0/24')
120
121 log.info("Delete nsslapd-haproxy-trusted-ip attribute")
122 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
123
124 log.info("Check that nsslapd-haproxy-trusted-ip attribute is not present")
125 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.0/24')
126
127
128 def test_haproxy_trust_ip_subnet_ipv6(topo):
129 """Test nsslapd-haproxy-trusted-ip with IPv6 CIDR subnet notation
130
131 :id: 711d134d-0e26-47e1-8144-8c8aa6c73757
132 :setup: Standalone instance
133 :steps:
134 1. Set nsslapd-haproxy-trusted-ip to an IPv6 subnet (2001:db8::/32)
135 2. Check that the subnet is present
136 3. Delete the attribute
137 :expectedresults:
138 1. Success
139 2. Success
140 3. Success
141 """
142 log.info("Set nsslapd-haproxy-trusted-ip to IPv6 subnet")
143 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '2001:db8::/32')
144
145 log.info("Check that nsslapd-haproxy-trusted-ip subnet is present")
146 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '2001:db8::/32')
147
148 log.info("Delete nsslapd-haproxy-trusted-ip attribute")
149 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
150
151 log.info("Check that nsslapd-haproxy-trusted-ip attribute is not present")
152 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '2001:db8::/32')
153
154
155 def test_haproxy_trust_ip_mixed_values(topo):
156 """Test nsslapd-haproxy-trusted-ip with mixed individual IPs and subnets
157
158 :id: 0a4e8826-7db1-4c3a-bfba-a2483d0f69d2
159 :setup: Standalone instance
160 :steps:
161 1. Set nsslapd-haproxy-trusted-ip to multiple values including IPs and subnets
162 2. Check that all values are present
163 3. Delete the attribute
164 :expectedresults:
165 1. Success
166 2. Success
167 3. Success
168 """
169 log.info("Set nsslapd-haproxy-trusted-ip to mixed values")
170 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', ['192.168.0.0/24', '10.0.0.1', '2001:db8::/64'])
171
172 log.info("Check that all values are present")
173 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.0/24')
174 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '10.0.0.1')
175 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '2001:db8::/64')
176
177 log.info("Delete nsslapd-haproxy-trusted-ip attribute")
178 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
179
180 log.info("Check that nsslapd-haproxy-trusted-ip attribute is not present")
181 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.0.0/24')
182
183
184 def test_haproxy_trust_ip_buffer_overflow_protection(topo):
185 """Test nsslapd-haproxy-trusted-ip rejects oversized strings (buffer overflow protection)
186
187 :id: 96b63d88-3ec9-4b70-84f1-e48dfeadd293
188 :setup: Standalone instance
189 :steps:
190 1. Try to set nsslapd-haproxy-trusted-ip with a string longer than 256 characters
191 2. Verify the operation is rejected
192 :expectedresults:
193 1. Operation should fail with LDAP_OPERATIONS_ERROR
194 2. Attribute should not be set
195 """
196 log.info("Attempt to set oversized IP string (buffer overflow test)")
197 oversized_ip = "192.168.1." + "0" * 300 # 300+ character string
198
199 with pytest.raises(ldap.OPERATIONS_ERROR):
200 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', oversized_ip)
201
202 log.info("Verify attribute was not set")
203 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', oversized_ip)
204
205
206 def test_haproxy_trust_ip_invalid_cidr_multiple_slashes(topo):
207 """Test nsslapd-haproxy-trusted-ip rejects multiple slashes in CIDR notation
208
209 :id: 38a7eb6e-cec8-47c5-aba8-79bc9511127f
210 :setup: Standalone instance
211 :steps:
212 1. Try to set CIDR with multiple slashes (192.168.1.0/24/32)
213 2. Verify the operation is rejected
214 :expectedresults:
215 1. Operation should fail
216 2. Attribute should not be set
217 """
218 log.info("Attempt to set CIDR with multiple slashes")
219
220 with pytest.raises(ldap.OPERATIONS_ERROR):
221 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/24/32')
222
223 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.1.0/24/32')
224
225
226 def test_haproxy_trust_ip_invalid_cidr_empty_prefix(topo):
227 """Test nsslapd-haproxy-trusted-ip rejects empty CIDR prefix
228
229 :id: 75ed1fc1-a30a-4913-9d1f-fcf14745f876
230 :setup: Standalone instance
231 :steps:
232 1. Try to set CIDR with empty prefix (192.168.1.0/)
233 2. Verify the operation is rejected
234 :expectedresults:
235 1. Operation should fail
236 2. Attribute should not be set
237 """
238 log.info("Attempt to set CIDR with empty prefix")
239
240 with pytest.raises(ldap.OPERATIONS_ERROR):
241 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/')
242
243 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.1.0/')
244
245
246 def test_haproxy_trust_ip_invalid_cidr_non_numeric_prefix(topo):
247 """Test nsslapd-haproxy-trusted-ip rejects non-numeric CIDR prefix
248
249 :id: 7acdadb5-a809-4aae-a6b3-ea6fe8f37ff5
250 :setup: Standalone instance
251 :steps:
252 1. Try to set CIDR with non-numeric prefix (192.168.1.0/abc)
253 2. Try to set CIDR with special characters (192.168.1.0/24!)
254 3. Verify both operations are rejected
255 :expectedresults:
256 1. Operation should fail
257 2. Operation should fail
258 3. Attributes should not be set
259 """
260 log.info("Attempt to set CIDR with non-numeric prefix")
261
262 with pytest.raises(ldap.OPERATIONS_ERROR):
263 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/abc')
264
265 with pytest.raises(ldap.OPERATIONS_ERROR):
266 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/24!')
267
268 with pytest.raises(ldap.OPERATIONS_ERROR):
269 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/2 4')
270
271 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.1.0/abc')
272
273
274 def test_haproxy_trust_ip_invalid_cidr_prefix_out_of_range(topo):
275 """Test nsslapd-haproxy-trusted-ip rejects out-of-range CIDR prefixes
276
277 :id: d60ebd80-9e2e-4c85-8d3b-076a24d2e063
278 :setup: Standalone instance
279 :steps:
280 1. Try to set IPv4 CIDR with prefix > 32
281 2. Try to set IPv6 CIDR with prefix > 128
282 3. Verify both operations are rejected
283 :expectedresults:
284 1. Operation should fail
285 2. Operation should fail
286 3. Attributes should not be set
287 """
288 log.info("Attempt to set IPv4 CIDR with prefix > 32")
289
290 with pytest.raises(ldap.OPERATIONS_ERROR):
291 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/33')
292
293 with pytest.raises(ldap.OPERATIONS_ERROR):
294 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.0/64')
295
296 log.info("Attempt to set IPv6 CIDR with prefix > 128")
297
298 with pytest.raises(ldap.OPERATIONS_ERROR):
299 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '2001:db8::/129')
300
301 with pytest.raises(ldap.OPERATIONS_ERROR):
302 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '2001:db8::/256')
303
304
305 def test_haproxy_trust_ip_invalid_characters(topo):
306 """Test nsslapd-haproxy-trusted-ip rejects IPs with invalid characters
307
308 :id: 7eaf95f1-1477-477d-b743-7415801c395d
309 :setup: Standalone instance
310 :steps:
311 1. Try to set IP with invalid characters
312 2. Try to set CIDR with wildcards (not allowed in CIDR)
313 3. Verify operations are rejected
314 :expectedresults:
315 1. Operation should fail
316 2. Operation should fail
317 3. Attributes should not be set
318 """
319 log.info("Attempt to set IP with invalid characters")
320
321 # Invalid characters in regular IP
322 with pytest.raises(ldap.OPERATIONS_ERROR):
323 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.x')
324
325 with pytest.raises(ldap.OPERATIONS_ERROR):
326 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.1@')
327
328 # Wildcards not allowed in any format
329 log.info("Attempt to set CIDR with wildcards (should be rejected)")
330 with pytest.raises(ldap.OPERATIONS_ERROR):
331 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.*/24')
332
333 # Wildcards not allowed in individual IPs either
334 log.info("Attempt to set individual IP with wildcard (should be rejected)")
335 with pytest.raises(ldap.OPERATIONS_ERROR):
336 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.*')
337
338 # Invalid IPv6 characters
339 with pytest.raises(ldap.OPERATIONS_ERROR):
340 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '2001:db8::gggg')
341
342
343 def test_haproxy_trust_ip_cidr_boundary_values(topo):
344 """Test nsslapd-haproxy-trusted-ip with boundary CIDR prefix values
345
346 :id: 7cbb711b-4366-4c23-8ec0-e64174081840
347 :setup: Standalone instance
348 :steps:
349 1. Test /0 prefix (matches everything)
350 2. Test /32 prefix for IPv4 (exact match)
351 3. Test /128 prefix for IPv6 (exact match)
352 4. Clean up
353 :expectedresults:
354 1. Success
355 2. Success
356 3. Success
357 4. Success
358 """
359 log.info("Set IPv4 /0 (matches all)")
360 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '0.0.0.0/0')
361 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '0.0.0.0/0')
362 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
363
364 log.info("Set IPv4 /32 (exact match)")
365 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '192.168.1.1/32')
366 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '192.168.1.1/32')
367 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
368
369 log.info("Set IPv6 /0 (matches all)")
370 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '::/0')
371 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '::/0')
372 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
373
374 log.info("Set IPv6 /128 (exact match)")
375 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', '2001:db8::1/128')
376 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', '2001:db8::1/128')
377 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
378
379
380 def test_haproxy_trust_ip_invalid_formats_comprehensive(topo):
381 """Test comprehensive validation of invalid IP formats
382
383 :id: 3b5b8082-de75-46b0-b53d-12d87da10f34
384 :setup: Standalone instance
385 :steps:
386 1. Test various malformed CIDR notations
387 2. Test invalid IP address formats
388 3. Test edge cases and attack vectors
389 :expectedresults:
390 1. All invalid formats should be rejected
391 2. No attributes should be set
392 3. Server should remain stable
393 """
394 log.info("Test malformed CIDR notations")
395
396 invalid_cidrs = [
397 '192.168.1.0/', # Empty prefix
398 '192.168.1.0/24/32', # Multiple slashes
399 '192.168.1.0/abc', # Non-numeric prefix
400 '192.168.1.0/24!', # Special chars in prefix
401 '192.168.1.0/ 24', # Space in prefix
402 '192.168.1.0/-1', # Negative prefix
403 '192.168.1.0/33', # IPv4 prefix > 32
404 '192.168.1.0/999', # Way out of range
405 '192.168.1.*/24', # Wildcard in CIDR (rejected)
406 '2001:db8::/', # IPv6 empty prefix
407 '2001:db8::/129', # IPv6 prefix > 128
408 '2001:db8::/abc', # IPv6 non-numeric prefix
409 '2001:db8::*/64', # IPv6 wildcard in CIDR (rejected)
410 ]
411
412 for invalid_cidr in invalid_cidrs:
413 log.info(f"Testing invalid CIDR: {invalid_cidr}")
414 with pytest.raises(ldap.OPERATIONS_ERROR):
415 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', invalid_cidr)
416 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', invalid_cidr)
417
418 log.info("Test invalid IP address formats")
419
420 invalid_ips = [
421 '256.168.1.1', # IPv4 octet > 255
422 '192.168.1', # Incomplete IPv4
423 '192.168.1.1.1', # Too many octets
424 '192.168.1.x', # Invalid character
425 '192.168.1.1@', # Special character
426 '192.168.1.1#comment', # Comment-like
427 '192.168.1.*', # Wildcard (rejected)
428 '192.168.*.*', # Multiple wildcards (rejected)
429 '2001:db8::gggg', # Invalid hex in IPv6
430 '2001:db8::1::2', # Double :: in IPv6
431 '2001:db8::*', # IPv6 wildcard (rejected)
432 'not.an.ip.address', # Alphabetic
433 ]
434
435 for invalid_ip in invalid_ips:
436 log.info(f"Testing invalid IP: {invalid_ip}")
437 with pytest.raises(ldap.OPERATIONS_ERROR):
438 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', invalid_ip)
439 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', invalid_ip)
440
441
442 def test_haproxy_trust_ip_security_attack_vectors(topo):
443 """Test nsslapd-haproxy-trusted-ip against potential security attack vectors
444
445 :id: 20890d58-ba62-41bf-8484-66144dc143d7
446 :setup: Standalone instance
447 :steps:
448 1. Test buffer overflow attempts
449 2. Test format string attacks
450 3. Test injection attempts
451 :expectedresults:
452 1. All attacks should be rejected safely
453 2. Server should not crash
454 3. No attributes should be set
455 """
456 log.info("Test potential attack vectors")
457
458 attack_vectors = [
459 'A' * 300, # Buffer overflow attempt
460 '192.168.1.0' + '/24' * 50, # Repeated slashes
461 '192.168.1.0/24\x00/32', # Null byte injection
462 '../../../etc/passwd', # Path traversal attempt
463 '192.168.1.0/$(whoami)', # Command injection attempt
464 '192.168.1.0/%s%s%s%s', # Format string attempt
465 '192.168.1.0/24\r\n192.168.2.0/24', # CRLF injection
466 ]
467
468 for attack in attack_vectors:
469 log.info(f"Testing attack vector: {attack[:50]}...") # Log first 50 chars
470 with pytest.raises(ldap.OPERATIONS_ERROR):
471 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', attack)
472
473 log.info("Server remained stable after attack attempts")
474
475
476 def test_haproxy_trust_ip_additional_edge_cases(topo):
477 """Test nsslapd-haproxy-trusted-ip with additional validation edge cases
478
479 :id: c0ed7407-5bbd-4b08-86ae-d0174c59b92b
480 :setup: Standalone instance
481 :steps:
482 1. Test leading zeros in prefix (should be rejected or normalized)
483 2. Test integer overflow in prefix
484 3. Test whitespace handling
485 4. Test case sensitivity
486 :expectedresults:
487 1. All invalid formats should be rejected
488 2. Server should remain stable
489 """
490 log.info("Test additional edge cases for validation")
491
492 additional_invalid = [
493 '192.168.1.0/024', # Leading zeros in prefix
494 '192.168.1.0/99999999999999999', # Integer overflow in prefix
495 ' 192.168.1.0/24', # Leading whitespace
496 '192.168.1.0/24 ', # Trailing whitespace
497 '192.168.1.0 /24', # Space before slash
498 '192.168. 1.0/24', # Space in IP
499 '2001:db8::/0x20', # Hex notation in prefix
500 '192.168.1.0/+24', # Plus sign in prefix
501 ]
502
503 for invalid in additional_invalid:
504 log.info(f"Testing additional invalid: {invalid}")
505 with pytest.raises(ldap.OPERATIONS_ERROR):
506 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', invalid)
507 assert not topo.standalone.config.present('nsslapd-haproxy-trusted-ip', invalid)
508
509 log.info("Additional edge cases handled correctly")
510
511
512 def test_haproxy_trust_ip_valid_edge_cases(topo):
513 """Test nsslapd-haproxy-trusted-ip with valid edge cases
514
515 :id: 82a14e70-475b-423d-9e6e-52a89b2f0506
516 :setup: Standalone instance
517 :steps:
518 1. Test various valid CIDR prefix lengths
519 2. Test localhost addresses
520 3. Test private network ranges
521 4. Clean up
522 :expectedresults:
523 1. All valid formats should be accepted
524 2. All values should be retrievable
525 3. Clean up successful
526 """
527 log.info("Test various valid CIDR prefix lengths")
528
529 valid_configs = [
530 '10.0.0.0/8', # Class A network
531 '172.16.0.0/12', # Private network
532 '192.168.0.0/16', # Class C network
533 '192.0.2.0/24', # TEST-NET-1
534 '198.51.100.0/24', # TEST-NET-2
535 '203.0.113.0/24', # TEST-NET-3
536 '127.0.0.1/32', # Localhost exact
537 '::1/128', # IPv6 localhost
538 'fe80::/10', # IPv6 link-local
539 '2001:db8::/32', # IPv6 documentation
540 'fc00::/7', # IPv6 unique local
541 ]
542
543 for valid_config in valid_configs:
544 log.info(f"Testing valid config: {valid_config}")
545 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', valid_config)
546 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', valid_config)
547 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
548
549 log.info("All valid edge cases handled correctly")
550
551
552 def test_haproxy_trust_ip_performance_optimizations(topo):
553 """Test that performance optimizations don't break functionality
554
555 :id: e10cfdc4-8d5e-4240-a457-cab75a481ad1
556 :setup: Standalone instance
557 :steps:
558 1. Set multiple mixed IP/subnet values
559 2. Verify all values are stored correctly
560 3. Verify parsed binary format is created
561 4. Clean up
562 :expectedresults:
563 1. All values should be accepted
564 2. All values should be retrievable
565 3. Server should handle the configuration correctly
566 """
567 log.info("Test performance optimizations with mixed values")
568
569 mixed_values = [
570 '192.168.1.0/24', # IPv4 subnet
571 '10.0.0.1', # IPv4 single IP
572 '2001:db8::/32', # IPv6 subnet
573 'fe80::1', # IPv6 single IP
574 '172.16.0.0/12', # Another IPv4 subnet
575 '::ffff:192.168.1.50', # IPv4-mapped IPv6
576 ]
577
578 log.info("Set mixed IP/subnet values")
579 topo.standalone.config.set('nsslapd-haproxy-trusted-ip', mixed_values)
580
581 log.info("Verify all values are present")
582 for value in mixed_values:
583 assert topo.standalone.config.present('nsslapd-haproxy-trusted-ip', value), \
584 f"Value {value} should be present"
585
586 log.info("Clean up")
587 topo.standalone.config.remove_all('nsslapd-haproxy-trusted-ip')
588
589 log.info("Performance optimization test passed")