Debian Codegraph @

dirsrvtests/tests/suites/tls/tls_renegotiation_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2026 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 logging
10 import os
11 import pytest
12 from test389.topologies import topology_st as topo
13 from lib389.config import Encryption
14
15 pytestmark = pytest.mark.tier2
16
17 DEBUGGING = os.getenv("DEBUGGING", default=False)
18 if DEBUGGING:
19 logging.getLogger(__name__).setLevel(logging.DEBUG)
20 else:
21 logging.getLogger(__name__).setLevel(logging.INFO)
22 log = logging.getLogger(__name__)
23
24
25 def test_tls_renegotiation_config(topo):
26 """Test nsTLSAllowClientRenegotiation setting can be configured
27
28 :id: 54e5be6a-201d-457c-9b65-59ced0a5069e
29 :setup: Standalone instance with TLS enabled
30 :steps:
31 1. Enable TLS on standalone instance
32 2. Set nsTLSAllowClientRenegotiation to off and verify
33 3. Set nsTLSAllowClientRenegotiation to on and verify
34 4. Set nsTLSAllowClientRenegotiation to invalid value and verify it's accepted
35 :expectedresults:
36 1. TLS is enabled successfully
37 2. Setting is updated to off
38 3. Setting is updated to on
39 4. Setting is updated to invalid value (server accepts it)
40 """
41
42 log.info('Enabling TLS on standalone instance')
43 topo.standalone.enable_tls()
44 enc = Encryption(topo.standalone)
45
46 log.info('Setting nsTLSAllowClientRenegotiation to off')
47 enc.replace('nsTLSAllowClientRenegotiation', 'off')
48 topo.standalone.restart()
49
50 log.info('Verifying nsTLSAllowClientRenegotiation is set to off')
51 value = enc.get_attr_val_utf8('nsTLSAllowClientRenegotiation')
52 assert value == 'off', f'Expected off, got {value}'
53 log.info('Successfully set nsTLSAllowClientRenegotiation to off')
54
55 log.info('Setting nsTLSAllowClientRenegotiation to on')
56 enc.replace('nsTLSAllowClientRenegotiation', 'on')
57 topo.standalone.restart()
58
59 log.info('Verifying nsTLSAllowClientRenegotiation is set to on')
60 value = enc.get_attr_val_utf8('nsTLSAllowClientRenegotiation')
61 assert value == 'on', f'Expected on, got {value}'
62 log.info('Successfully set nsTLSAllowClientRenegotiation to on')
63
64 log.info('Setting nsTLSAllowClientRenegotiation to invalid value')
65 enc.replace('nsTLSAllowClientRenegotiation', 'invalid')
66 topo.standalone.restart()
67
68 log.info('Verifying nsTLSAllowClientRenegotiation accepts invalid value')
69 value = enc.get_attr_val_utf8('nsTLSAllowClientRenegotiation')
70 assert value == 'invalid', f'Expected invalid, got {value}'
71 log.info('Server accepted invalid value for nsTLSAllowClientRenegotiation')
72
73
74 if __name__ == '__main__':
75 CURRENT_FILE = os.path.realpath(__file__)
76 pytest.main(["-s", CURRENT_FILE])