Debian Codegraph @

dirsrvtests/tests/suites/mapping_tree/acceptance_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2020 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 import os
13 from lib389._constants import *
14 from test389.topologies import topology_st as topo
15 from lib389.mappingTree import MappingTrees
16
17 pytestmark = pytest.mark.tier1
18
19 DEBUGGING = os.getenv("DEBUGGING", default=False)
20 if DEBUGGING:
21 logging.getLogger(__name__).setLevel(logging.DEBUG)
22 else:
23 logging.getLogger(__name__).setLevel(logging.INFO)
24 log = logging.getLogger(__name__)
25
26
27 def test_invalid_mt(topo):
28 """Test that you can not add a new suffix/mapping tree
29 that does not already have the backend entry created.
30
31 :id: caabd407-f541-4695-b13f-8f92af1112a0
32 :setup: Standalone Instance
33 :steps:
34 1. Create a new suffix that specifies an existing backend which has a
35 different suffix.
36 2. Create a suffix that has no backend entry at all.
37 :expectedresults:
38 1. Should fail with UNWILLING_TO_PERFORM
39 1. Should fail with UNWILLING_TO_PERFORM
40 """
41
42 bad_suffix = 'dc=does,dc=not,dc=exist'
43 mts = MappingTrees(topo.standalone)
44
45 properties = {
46 'cn': bad_suffix,
47 'nsslapd-state': 'backend',
48 'nsslapd-backend': 'userroot',
49 }
50 with pytest.raises(ldap.UNWILLING_TO_PERFORM):
51 mts.create(properties=properties)
52
53 properties = {
54 'cn': bad_suffix,
55 'nsslapd-state': 'backend',
56 'nsslapd-backend': 'notCreatedRoot',
57 }
58 with pytest.raises(ldap.UNWILLING_TO_PERFORM):
59 mts.create(properties=properties)
60
61
62 if __name__ == '__main__':
63 # Run isolated
64 # -s for DEBUG mode
65 CURRENT_FILE = os.path.realpath(__file__)
66 pytest.main(["-s", CURRENT_FILE])
67