-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbug515329.py
305 lines (278 loc) · 9.24 KB
/
bug515329.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
from bug_harness import DSAdminHarness as DSAdmin
from dsadmin import Entry, LEAF_TYPE
import os
import sys
import time
import ldap
host1 = "localhost.localdomain"
host2 = host1
host3 = host2
port1 = 1200
port2 = port1+10
port3 = port2+10
basedn = "dc=example,dc=com"
m1replargs = {
'suffix': basedn,
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl",
'pd': 5,
'log' : False
}
m2replargs = m1replargs
m1 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': basedn,
'verbose': True,
'no_admin': True
})
#os.environ['USE_GDB'] = "1"
m2 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host2,
'newport': port2,
'newinst': 'm2',
'newsuffix': basedn,
'verbose': False,
'no_admin': True
})
#del os.environ['USE_GDB']
c1 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host3,
'newport': port3,
'newinst': 'c1',
'newsuffix': basedn,
'no_admin': True
})
m1.replicaSetupAll(m1replargs)
m2.replicaSetupAll(m2replargs)
c1replargs = m1replargs
c1replargs['type'] = LEAF_TYPE
c1.replicaSetupAll(c1replargs)
print "create agreements and init consumers"
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
time.sleep(2)
m1.startReplication(agmtm1tom2)
print "repl status after starting"
print m1.getReplStatus(agmtm1tom2)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)
agmtm1toc1 = m1.setupAgreement(c1, m1replargs)
time.sleep(2)
m1.startReplication(agmtm1toc1)
print "repl status after starting"
print m1.getReplStatus(agmtm1toc1)
agmtm2toc1 = m2.setupAgreement(c1, m2replargs)
print "add entry on m1 . . ."
dn = 'uid=testuser,dc=example,dc=com'
ent = Entry(dn)
ent.setValues('objectclass', 'inetOrgPerson')
ent.setValues('cn', "1")
ent.setValues('sn', 'testuser')
m1.add_s(ent)
time.sleep(2)
print "search for entry on m2 . . ."
ents = m2.search_s(dn, ldap.SCOPE_BASE)
if not ents:
time.sleep(2)
ents = m2.search_s(dn, ldap.SCOPE_BASE)
if not ents:
print "entry not found on m2"
sys.exit(1)
else:
print "entry found on m2"
print "search for entry on c1 . . ."
ents = c1.search_s(dn, ldap.SCOPE_BASE)
if not ents:
time.sleep(2)
ents = c1.search_s(dn, ldap.SCOPE_BASE)
if not ents:
print "entry not found on c1"
sys.exit(1)
else:
print "entry found on c1"
print "modify entry on m1 . . ."
mod = [(ldap.MOD_ADD, 'cn', '2'),
(ldap.MOD_REPLACE, 'cn', '3'),
(ldap.MOD_ADD, 'cn', '4'),
(ldap.MOD_DELETE, 'cn', '3'),
(ldap.MOD_ADD, 'cn', '5'),
(ldap.MOD_DELETE, 'cn', '4'),
(ldap.MOD_REPLACE, 'description', '1'),
(ldap.MOD_REPLACE, 'description', None),
(ldap.MOD_ADD, 'sn', '2'),
(ldap.MOD_REPLACE, 'sn', '3'),
(ldap.MOD_ADD, 'sn', '4'),
(ldap.MOD_DELETE, 'sn', '3'),
(ldap.MOD_ADD, 'sn', '5'),
(ldap.MOD_REPLACE, 'sn', ['6', '7', '8'])]
expectval = '5'
expectvalsn = ['6', '7', '8']
m1.modify_s(dn, mod)
time.sleep(5)
print "search for entry on m2 . . ."
attrlist = ['cn', 'sn', 'nscpentrywsi']
ents = m2.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m2 entry is correct"
else:
print "value of m2 entry is not correct:", ent.cn
print "value of m2 entry is not correct:", ent.sn
print "entrywsi:", str(ent)
print "search for entry on m1 . . ."
ents = m1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m1 entry is correct"
else:
print "value of m1 entry is not correct:", ent.cn
print "value of m1 entry is not correct:", ent.sn
print "entrywsi:", str(ent)
print "search for entry on c1 . . ."
ents = c1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of c1 entry is correct"
else:
print "value of c1 entry is not correct:", ent.cn
print "value of c1 entry is not correct:", ent.sn
print "entrywsi:", str(ent)
mod = [(ldap.MOD_ADD, 'cn', '6'),
(ldap.MOD_REPLACE, 'cn', '7'),
(ldap.MOD_ADD, 'cn', '8'),
(ldap.MOD_DELETE, 'cn', '7'),
(ldap.MOD_ADD, 'cn', '9'),
(ldap.MOD_DELETE, 'cn', '8'),
(ldap.MOD_REPLACE, 'description', '2'),
(ldap.MOD_REPLACE, 'description', None),
(ldap.MOD_DELETE, 'sn', ['6', '7', '8']),
(ldap.MOD_REPLACE, 'sn', ['9', '10', '11'])]
expectval = '9'
expectvalsn = ['9', '10', '11']
m1.modify_s(dn, mod)
time.sleep(5)
print "search for entry on m2 . . ."
ents = m2.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m2 entry is correct"
else:
print "value of m2 entry is not correct:", ent.cn
print "value of m2 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on m1 . . ."
ents = m1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m1 entry is correct"
else:
print "value of m1 entry is not correct:", ent.cn
print "value of m1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on c1 . . ."
ents = c1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of c1 entry is correct"
else:
print "value of c1 entry is not correct:", ent.cn
print "value of c1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
mod = [(ldap.MOD_ADD, 'cn', '10'),
(ldap.MOD_REPLACE, 'cn', '11'),
(ldap.MOD_ADD, 'cn', '12'),
(ldap.MOD_DELETE, 'cn', '11'),
(ldap.MOD_ADD, 'cn', '13'),
(ldap.MOD_DELETE, 'cn', '12'),
(ldap.MOD_REPLACE, 'description', '3'),
(ldap.MOD_REPLACE, 'description', None),
(ldap.MOD_DELETE, 'sn', ['9', '10', '11']),
(ldap.MOD_REPLACE, 'sn', ['12', '13', '14'])]
expectval = '13'
expectvalsn = ['12', '13', '14']
#c1.setLogLevel(8192)
m1.modify_s(dn, mod)
time.sleep(5)
print "search for entry on m2 . . ."
ents = m2.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m2 entry is correct"
else:
print "value of m2 entry is not correct:", ent.cn
print "value of m2 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on m1 . . ."
ents = m1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m1 entry is correct"
else:
print "value of m1 entry is not correct:", ent.cn
print "value of m1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on c1 . . ."
ents = c1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of c1 entry is correct"
else:
print "value of c1 entry is not correct:", ent.cn
print "value of c1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
mod = [(ldap.MOD_ADD, 'cn', '14'),
(ldap.MOD_REPLACE, 'cn', '15'),
(ldap.MOD_ADD, 'cn', '16'),
(ldap.MOD_DELETE, 'cn', '15'),
(ldap.MOD_ADD, 'cn', '17'),
(ldap.MOD_DELETE, 'cn', '16'),
(ldap.MOD_REPLACE, 'description', '4'),
(ldap.MOD_REPLACE, 'description', None),
(ldap.MOD_DELETE, 'sn', ['12', '13', '14']),
(ldap.MOD_REPLACE, 'sn', ['15', '16', '17'])]
expectval = '17'
expectvalsn = ['15', '16', '17']
c1.setLogLevel(8192)
m1.modify_s(dn, mod)
time.sleep(5)
print "search for entry on m2 . . ."
ents = m2.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m2 entry is correct"
else:
print "value of m2 entry is not correct:", ent.cn
print "value of m2 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on m1 . . ."
ents = m1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of m1 entry is correct"
else:
print "value of m1 entry is not correct:", ent.cn
print "value of m1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)
print "search for entry on c1 . . ."
ents = c1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*', attrlist)
ent = ents[0]
if ent.cn == expectval and ent.hasValue('sn', expectvalsn):
print "value of c1 entry is correct"
else:
print "value of c1 entry is not correct:", ent.cn
print "value of c1 entry is not correct:", ent.sn
print "See if the old state information has been removed"
print "entrywsi:", str(ent)