Debian Codegraph @

dirsrvtests/tests/suites/tls/tls_ldaps_only_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2020 William Brown <[email protected]
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 pytest
10 import ldap
11 from test389.topologies import topology_st
12 from lib389.utils import socket_check_open
13
14 pytestmark = pytest.mark.tier1
15
16 def test_tls_ldaps_only(topology_st):
17 """Test that the server can run with ldaps only.
18
19 :id: 812d806b-9368-4534-a291-cbc60ac92a23
20 :steps:
21 1. Enable TLS
22 2. Set the server to ldaps only and restart
23 3. Set the server to accept both and restart
24 :expectedresults:
25 1. TlS is setup
26 2. The server only works on ldaps
27 3. The server accepts both.
28 """
29 standalone = topology_st.standalone
30 # Enable TLS
31 standalone.enable_tls()
32 # Remember the existing port for later.
33 plain_port = standalone.config.get_attr_val_utf8('nsslapd-port')
34 tls_port = standalone.config.get_attr_val_utf8('nsslapd-securePort')
35 # Disable the plaintext port
36 standalone.config.disable_plaintext_port()
37 standalone.restart()
38 # Check we only have the tls port
39 nport = standalone.config.get_attr_val_utf8('nsslapd-port')
40 assert(nport == '0');
41 # Setup the plain again.
42 standalone.config.enable_plaintext_port(plain_port)
43 standalone.restart()
44 nport = standalone.config.get_attr_val_utf8('nsslapd-port')
45 assert(nport == plain_port);
46