Debian Codegraph @

dirsrvtests/tests/suites/openldap_2_389/migrate_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 os
11 from test389.topologies import topology_st
12 from lib389.utils import ds_is_older
13 from lib389.migrate.openldap.config import olConfig
14 from lib389.migrate.openldap.config import olOverlayType
15 from lib389.migrate.plan import Migration
16 # from lib389.migrate.plan import *
17
18 pytestmark = pytest.mark.tier1
19
20 DATADIR1 = os.path.join(os.path.dirname(__file__), '../../data/openldap_2_389/1/')
21
22 @pytest.mark.skipif(ds_is_older('1.4.3'), reason="Not implemented")
23 def test_parse_openldap_slapdd():
24 """Test parsing an example openldap configuration. We should be able to
25 at least determine the backends, what overlays they have, and some other
26 minimal amount.
27
28 :id: b0061ab0-fff4-45c6-b6c6-171ca3d2dfbc
29 :setup: Data directory with an openldap config directory.
30 :steps:
31 1. Parse the openldap configuration
32
33 :expectedresults:
34 1. Success
35 """
36 config_path = os.path.join(DATADIR1, 'slapd.d')
37 config = olConfig(config_path)
38
39 # Do we have databases?
40 assert len(config.databases) == 2
41 # Check that we unpacked uid eq,pres,sub correctly.
42 assert len(config.databases[0].index) == 4
43 assert ('objectClass', 'eq') in config.databases[0].index
44 assert ('uid', 'eq') in config.databases[0].index
45 assert ('uid', 'pres') in config.databases[0].index
46 assert ('uid', 'sub') in config.databases[0].index
47
48 # Did our schema parse?
49 assert any(['suseModuleConfiguration' in x.names for x in config.schema.classes])
50
51
52 @pytest.mark.skipif(ds_is_older('1.4.3'), reason="Not implemented")
53 def test_migrate_openldap_slapdd(topology_st):
54 """
55
56 :id: e9748040-90a0-4d69-bdde-007104f75cc5
57 :setup: Data directory with an openldap config directory.
58 :steps:
59 1. Parse the configuration
60 2. Execute a full migration plan
61
62 :expectedresults:
63 1. Success
64 2. Success
65 """
66
67 inst = topology_st.standalone
68 config_path = os.path.join(DATADIR1, 'slapd.d')
69 config = olConfig(config_path)
70 ldifs = {
71 "dc=example,dc=com": os.path.join(DATADIR1, 'example_com.slapcat.ldif'),
72 "dc=example,dc=net": os.path.join(DATADIR1, 'example_net.slapcat.ldif'),
73 }
74
75 migration = Migration(inst, config.schema, config.databases, ldifs)
76
77 print("==== migration plan ====")
78 print(migration.__unicode__())
79 print("==== end migration plan ====")
80
81 migration.execute_plan()
82
83 # Check the BE's are there
84 # Check plugins
85 # Check the schema
86 # Check a user can bind
87
88
89 @pytest.mark.skipif(ds_is_older('1.4.3'), reason="Not implemented")
90 def test_migrate_openldap_slapdd_skip_elements(topology_st):
91 """
92
93 :id: d5e16aeb-6810-423b-b5e0-f89e0596292e
94 :setup: Data directory with an openldap config directory.
95 :steps:
96 1. Parse the configuration
97 2. Execute a migration with skipped elements
98
99 :expectedresults:
100 1. Success
101 2. Success
102 """
103
104 inst = topology_st.standalone
105 config_path = os.path.join(DATADIR1, 'slapd.d')
106 config = olConfig(config_path)
107 ldifs = {
108 "dc=example,dc=com": os.path.join(DATADIR1, 'example_com.slapcat.ldif'),
109 }
110
111 # 1.3.6.1.4.1.5322.13.1.1 is namedObject, so check that isn't there
112
113 migration = Migration(inst, config.schema, config.databases, ldifs,
114 skip_schema_oids=['1.3.6.1.4.1.5322.13.1.1'],
115 skip_overlays=[olOverlayType.UNIQUE],
116 )
117
118 print("==== migration plan ====")
119 print(migration.__unicode__())
120 print("==== end migration plan ====")
121
122 migration.execute_plan()
123
124 # Check that the overlay ISNT there
125 # Check the schema that SHOULDNT be there.
126
127
128
129
130
131 # # how to convert the config
132 #
133 # # How to slapcat
134 #
135 # openldap_2_389 --config /etc/openldap/slapd.d --ldif "path"
136 #
137 #
138 # --confirm
139 # --ignore-overlay=X
140 # --ignore-schema-oid=X
141 # --no-overlays
142 # --no-passwords
143 # --no-schema
144 # --no-indexes
145 #
146 #
147 #
148 #
149 # Add skip overlay
150 # Add password Strip
151 # check userPasswords
152
153