Debian Codegraph @

test/testMockSyncStrategy.py

raw
1 """
2 """
3
4 # Created on 2015.02.3
5 #
6 # Author: Giovanni Cannata
7 #
8 # Copyright 2015 - 2020 Giovanni Cannata
9 #
10 # This file is part of ldap3.
11 #
12 # ldap3 is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License as published
14 # by the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
16 #
17 # ldap3 is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU Lesser General Public License for more details.
21 #
22 # You should have received a copy of the GNU Lesser General Public License
23 # along with ldap3 in the COPYING and COPYING.LESSER files.
24 # If not, see <http://www.gnu.org/licenses/>.
25
26
27 import unittest
28
29 from ldap3 import Server, Connection, MOCK_SYNC, MODIFY_ADD, MODIFY_REPLACE, MODIFY_DELETE, OFFLINE_EDIR_9_1_4,\
30 BASE, LEVEL, SUBTREE, AUTO_BIND_NO_TLS, NONE
31 from ldap3.core.exceptions import LDAPInvalidCredentialsResult, LDAPNoSuchObjectResult
32 from ldap3.protocol.rfc4512 import SchemaInfo, DsaInfo
33 from ldap3.protocol.schemas.edir914 import edir_9_1_4_dsa_info, edir_9_1_4_schema
34 from test.config import random_id
35
36 testcase_id = ''
37
38
39 class Test(unittest.TestCase):
40 def setUp(self):
41 global testcase_id
42 testcase_id = random_id()
43 # The mock server can be defined in two different ways, so tests are duplicated, connection_3 is without schema
44 schema = SchemaInfo.from_json(edir_9_1_4_schema)
45 info = DsaInfo.from_json(edir_9_1_4_dsa_info, schema)
46 server_1 = Server.from_definition('MockSyncServer', info, schema)
47 self.connection_1 = Connection(server_1, user='cn=user1,ou=test,o=lab', password='test1111', client_strategy=MOCK_SYNC)
48 self.connection_1b = Connection(server_1, user='cn=user1,ou=test,o=lab', password='test1111', client_strategy=MOCK_SYNC)
49 self.connection_1c = Connection(server_1, user='cn=user1,ou=test,o=lab', password='test1111', client_strategy=MOCK_SYNC, raise_exceptions=True)
50 server_2 = Server('dummy', get_info=OFFLINE_EDIR_9_1_4)
51 self.connection_2 = Connection(server_2, user='cn=user2,ou=test,o=lab', password='test2222', client_strategy=MOCK_SYNC)
52 self.connection_2b = Connection(server_2, user='cn=user2,ou=test,o=lab', password='test2222', client_strategy=MOCK_SYNC)
53 self.connection_2c = Connection(server_2, user='cn=user2,ou=test,o=lab', password='test2222', client_strategy=MOCK_SYNC, raise_exceptions=True)
54 server_3 = Server('dummy') # no schema
55 self.connection_3 = Connection(server_3, user='cn=user3,ou=test,o=lab', password='test3333', client_strategy=MOCK_SYNC)
56 self.connection_3b = Connection(server_3, user='cn=user3,ou=test,o=lab', password='test3333', client_strategy=MOCK_SYNC)
57 self.connection_3c = Connection(server_3, user='cn=user3,ou=test,o=lab', password='test3333', client_strategy=MOCK_SYNC, raise_exceptions=True)
58 # creates fixtures
59 self.connection_1.strategy.add_entry('cn=user0,o=lab', {'userPassword': 'test0000', 'sn': 'user0_sn', 'revision': 0, 'guid': '07039e68-4373-264d-a0a7-000000000000'})
60 self.connection_2.strategy.add_entry('cn=user0,o=lab', {'userPassword': 'test0000', 'sn': 'user0_sn', 'revision': 0, 'guid': '07039e68-4373-264d-a0a7-000000000000'})
61 self.connection_3.strategy.add_entry('cn=user0,o=lab', {'userPassword': 'test0000', 'sn': 'user0_sn', 'revision': 0, 'guid': '07039e68-4373-264d-a0a7-000000000000'})
62 self.connection_1.strategy.add_entry('cn=user1,ou=test,o=lab', {'userPassword': 'test1111', 'sn': 'user1_sn', 'revision': 1, 'guid': '07039e68-4373-264d-a0a7-111111111111'})
63 self.connection_2.strategy.add_entry('cn=user1,ou=test,o=lab', {'userPassword': 'test1111', 'sn': 'user1_sn', 'revision': 1, 'guid': '07039e68-4373-264d-a0a7-111111111111'})
64 self.connection_3.strategy.add_entry('cn=user1,ou=test,o=lab', {'userPassword': 'test1111', 'sn': 'user1_sn', 'revision': 1, 'guid': '07039e68-4373-264d-a0a7-111111111111'})
65 self.connection_1.strategy.add_entry('cn=user2,ou=test,o=lab', {'userPassword': 'test2222', 'sn': 'user2_sn', 'revision': 2, 'guid': '07039e68-4373-264d-a0a7-222222222222'})
66 self.connection_2.strategy.add_entry('cn=user2,ou=test,o=lab', {'userPassword': 'test2222', 'sn': 'user2_sn', 'revision': 2, 'guid': '07039e68-4373-264d-a0a7-222222222222'})
67 self.connection_3.strategy.add_entry('cn=user2,ou=test,o=lab', {'userPassword': 'test2222', 'sn': 'user2_sn', 'revision': 2, 'guid': '07039e68-4373-264d-a0a7-222222222222'})
68 self.connection_1.strategy.add_entry('cn=user3,ou=test,o=lab', {'userPassword': 'test3333', 'sn': 'user3_sn', 'revision': 3, 'guid': '07039e68-4373-264d-a0a7-333333333333'})
69 self.connection_2.strategy.add_entry('cn=user3,ou=test,o=lab', {'userPassword': 'test3333', 'sn': 'user3_sn', 'revision': 3, 'guid': '07039e68-4373-264d-a0a7-333333333333'})
70 self.connection_3.strategy.add_entry('cn=user3,ou=test,o=lab', {'userPassword': 'test3333', 'sn': 'user3_sn', 'revision': 3, 'guid': '07039e68-4373-264d-a0a7-333333333333'})
71 self.connection_1.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444', 'sn': 'user4_sn', 'revision': 4, 'title': ['title1', 'title2', 'title3'], 'guid': '07039e68-4373-264d-a0a7-444444444444'})
72 self.connection_2.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444', 'sn': 'user4_sn', 'revision': 4, 'title': ['title1', 'title2', 'title3'], 'guid': '07039e68-4373-264d-a0a7-444444444444'})
73 self.connection_3.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444', 'sn': 'user4_sn', 'revision': 4, 'title': ['title1', 'title2', 'title3'], 'guid': '07039e68-4373-264d-a0a7-444444444444'})
74
75 def tearDown(self):
76 self.connection_1.unbind()
77 self.assertFalse(self.connection_1.bound)
78 self.connection_2.unbind()
79 self.assertFalse(self.connection_2.bound)
80 self.connection_3.unbind()
81 self.assertFalse(self.connection_3.bound)
82
83 def test_open_1(self):
84 self.connection_1.open()
85 self.assertFalse(self.connection_1.closed)
86
87 def test_open_2(self):
88 self.connection_2.open()
89 self.assertFalse(self.connection_2.closed)
90
91 def test_open_3(self):
92 self.connection_3.open()
93 self.assertFalse(self.connection_3.closed)
94
95 def test_bind_1(self):
96 self.connection_1.open()
97 self.connection_1.bind()
98 self.assertTrue(self.connection_1.bound)
99
100 def test_bind_2(self):
101 self.connection_2.open()
102 self.connection_2.bind()
103 self.assertTrue(self.connection_2.bound)
104
105 def test_bind_3(self):
106 self.connection_3.open()
107 self.connection_3.bind()
108 self.assertTrue(self.connection_3.bound)
109
110 def test_invalid_bind_1(self):
111 self.connection_1.password = 'wrong'
112 self.connection_1.open()
113 self.connection_1.bind()
114 self.assertFalse(self.connection_1.bound)
115
116 def test_invalid_bind_2(self):
117 self.connection_2.password = 'wrong'
118 self.connection_2.open()
119 self.connection_2.bind()
120 self.assertFalse(self.connection_2.bound)
121
122 def test_invalid_bind_3(self):
123 self.connection_3.password = 'wrong'
124 self.connection_3.open()
125 self.connection_3.bind()
126 self.assertFalse(self.connection_3.bound)
127
128 def test_invalid_bind_exception_1(self):
129 self.connection_1c.password = 'wrong'
130 self.connection_1c.open()
131 try:
132 self.connection_1c.bind()
133 self.fail('exception not raised')
134 except LDAPInvalidCredentialsResult:
135 pass
136
137 def test_invalid_bind_exception_2(self):
138 self.connection_2c.password = 'wrong'
139 self.connection_2c.open()
140 try:
141 self.connection_2c.bind()
142 self.fail('exception not raised')
143 except LDAPInvalidCredentialsResult:
144 pass
145
146 def test_invalid_bind_exception_3(self):
147 self.connection_3c.password = 'wrong'
148 self.connection_3c.open()
149 try:
150 self.connection_3c.bind()
151 self.fail('exception not raised')
152 except LDAPInvalidCredentialsResult:
153 pass
154
155 def test_unbind_1(self):
156 self.connection_1.open()
157 self.assertFalse(self.connection_1.closed)
158 self.connection_1.bind()
159 self.assertTrue(self.connection_1.bound)
160 self.connection_1.unbind()
161 self.assertFalse(self.connection_1.bound)
162 self.assertTrue(self.connection_1.closed)
163
164 def test_unbind_2(self):
165 self.connection_2.open()
166 self.assertFalse(self.connection_2.closed)
167 self.connection_2.bind()
168 self.assertTrue(self.connection_2.bound)
169 self.connection_2.unbind()
170 self.assertFalse(self.connection_2.bound)
171 self.assertTrue(self.connection_2.closed)
172
173 def test_unbind_3(self):
174 self.connection_3.open()
175 self.assertFalse(self.connection_3.closed)
176 self.connection_3.bind()
177 self.assertTrue(self.connection_3.bound)
178 self.connection_3.unbind()
179 self.assertFalse(self.connection_3.bound)
180 self.assertTrue(self.connection_3.closed)
181
182 def test_add_user_1(self):
183 self.connection_1.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444'})
184 self.connection_1.rebind('cn=user4,ou=test,o=lab', 'test4444')
185 self.assertTrue(self.connection_1.bound)
186
187 def test_add_user_2(self):
188 self.connection_2.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444'})
189 self.connection_2.rebind('cn=user4,ou=test,o=lab', 'test4444')
190 self.assertTrue(self.connection_2.bound)
191
192 def test_add_user_3(self):
193 self.connection_3.strategy.add_entry('cn=user4,ou=test,o=lab', {'userPassword': 'test4444'})
194 self.connection_3.rebind('cn=user4,ou=test,o=lab', 'test4444')
195 self.assertTrue(self.connection_3.bound)
196
197 def test_remove_user_1(self):
198 self.connection_1.strategy.remove_entry('cn=user2,ou=test,o=lab')
199 self.connection_1.bind()
200 self.assertTrue(self.connection_1.bound)
201 self.connection_1.rebind('cn=user2,ou=test,o=lab', 'test9876')
202 self.assertFalse(self.connection_1.bound)
203
204 def test_remove_user_2(self):
205 self.connection_2.strategy.remove_entry('cn=user1,ou=test,o=lab')
206 self.connection_2.bind()
207 self.assertTrue(self.connection_2.bound)
208 self.connection_2.rebind('cn=user1,ou=test,o=lab', 'test9876')
209 self.assertFalse(self.connection_2.bound)
210
211 def test_remove_user_3(self):
212 self.connection_3.strategy.remove_entry('cn=user1,ou=test,o=lab')
213 self.connection_3.bind()
214 self.assertTrue(self.connection_3.bound)
215 self.connection_3.rebind('cn=user1,ou=test,o=lab', 'test1111')
216 self.assertFalse(self.connection_3.bound)
217
218 def test_delete_1(self):
219 self.connection_1.bind()
220 result = self.connection_1.delete('cn=user1,ou=test,o=lab')
221 if not self.connection_1.strategy.sync:
222 _, result = self.connection_1.get_response(result)
223 else:
224 result = self.connection_1.result
225
226 self.assertTrue(result['description'], 'success')
227 self.assertTrue('cn=user1,ou=test,o=lab' not in self.connection_1.strategy.entries)
228
229 def test_delete_2(self):
230 self.connection_2.bind()
231 result = self.connection_2.delete('cn=user2,ou=test,o=lab')
232 if not self.connection_2.strategy.sync:
233 _, result = self.connection_2.get_response(result)
234 else:
235 result = self.connection_2.result
236 self.assertTrue(['description'], 'success')
237 self.assertTrue('cn=user2,ou=test,o=lab' not in self.connection_2.strategy.entries)
238
239 def test_delete_3(self):
240 self.connection_3.bind()
241 result = self.connection_3.delete('cn=user3,ou=test,o=lab')
242 if not self.connection_3.strategy.sync:
243 _, result = self.connection_3.get_response(result)
244 else:
245 result = self.connection_3.result
246 self.assertTrue(result['description'], 'success')
247 self.assertTrue('cn=user3,ou=test,o=lab' not in self.connection_3.strategy.entries)
248
249 def test_add_entry_1(self):
250 dn = 'cn=user5,ou=test,o=lab'
251 self.connection_1.bind()
252 result = self.connection_1.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
253 if not self.connection_1.strategy.sync:
254 _, result = self.connection_1.get_response(result)
255 else:
256 result = self.connection_1.result
257 self.assertTrue(result['description'], 'success')
258 self.assertTrue(dn in self.connection_1.strategy.entries)
259 self.connection_1b.bind()
260 self.assertTrue(dn in self.connection_1b.strategy.entries)
261
262 def test_add_entry_2(self):
263 dn = 'cn=user5,ou=test,o=lab'
264 self.connection_2.bind()
265 result = self.connection_2.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
266 if not self.connection_2.strategy.sync:
267 _, result = self.connection_2.get_response(result)
268 else:
269 result = self.connection_2.result
270 self.assertTrue(result['description'], 'success')
271 self.assertTrue(dn in self.connection_2.strategy.entries)
272 self.connection_2b.bind()
273 self.assertTrue(dn in self.connection_2b.strategy.entries)
274
275 def test_add_entry_3(self):
276 dn = 'cn=user5,ou=test,o=lab'
277 self.connection_3.bind()
278 result = self.connection_3.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
279 if not self.connection_3.strategy.sync:
280 _, result = self.connection_3.get_response(result)
281 else:
282 result = self.connection_3.result
283 self.assertTrue(result['description'], 'success')
284 self.assertTrue(dn in self.connection_3.strategy.entries)
285 self.connection_3b.bind()
286 self.assertTrue(dn in self.connection_3b.strategy.entries)
287
288 def test_add_entry_already_exists_1(self):
289 dn = 'cn=user5,ou=test,o=lab'
290 self.connection_1.bind()
291 self.connection_1.strategy.add_entry(dn, {'objectClass': ['inetOrgPerson', 'top'], 'sn': 'user5_sn'})
292 result = self.connection_1.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
293 if not self.connection_1.strategy.sync:
294 _, result = self.connection_1.get_response(result)
295 else:
296 result = self.connection_1.result
297 self.assertEqual(result['description'], 'entryAlreadyExists')
298
299 def test_add_entry_already_exists_2(self):
300 dn = 'cn=user5,ou=test,o=lab'
301 self.connection_2.bind()
302 self.connection_2.strategy.add_entry(dn, {'objectClass': ['inetOrgPerson', 'top'], 'sn': 'user5_sn'})
303 result = self.connection_2.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
304 if not self.connection_2.strategy.sync:
305 _, result = self.connection_2.get_response(result)
306 else:
307 result = self.connection_2.result
308 self.assertEqual(result['description'], 'entryAlreadyExists')
309
310 def test_add_entry_already_exists_3(self):
311 dn = 'cn=user5,ou=test,o=lab'
312 self.connection_3.bind()
313 self.connection_3.strategy.add_entry(dn, {'objectClass': ['inetOrgPerson', 'top'], 'sn': 'user5_sn'})
314 result = self.connection_3.add(dn, ['inetOrgPerson', 'top'], {'sn': 'user5_sn'})
315 if not self.connection_3.strategy.sync:
316 _, result = self.connection_3.get_response(result)
317 else:
318 result = self.connection_3.result
319 self.assertEqual(result['description'], 'entryAlreadyExists')
320
321 def test_delete_entry_nonexisting_1(self):
322 dn = 'cn=user5,ou=test,o=lab'
323 self.connection_1.bind()
324 self.assertTrue(dn not in self.connection_1.strategy.entries)
325 result = self.connection_1.delete(dn)
326 if not self.connection_1.strategy.sync:
327 _, result = self.connection_1.get_response(result)
328 else:
329 result = self.connection_1.result
330 self.assertEqual(result['description'], 'noSuchObject')
331
332 def test_delete_entry_nonexisting_2(self):
333 dn = 'cn=user5,ou=test,o=lab'
334 self.connection_2.bind()
335 self.assertTrue(dn not in self.connection_2.strategy.entries)
336 result = self.connection_2.delete(dn)
337 if not self.connection_2.strategy.sync:
338 _, result = self.connection_2.get_response(result)
339 else:
340 result = self.connection_2.result
341 self.assertEqual(result['description'], 'noSuchObject')
342
343 def test_delete_entry_nonexisting_3(self):
344 dn = 'cn=user5,ou=test,o=lab'
345 self.connection_3.bind()
346 self.assertTrue(dn not in self.connection_3.strategy.entries)
347 result = self.connection_3.delete(dn)
348 if not self.connection_3.strategy.sync:
349 _, result = self.connection_3.get_response(result)
350 else:
351 result = self.connection_3.result
352 self.assertEqual(result['description'], 'noSuchObject')
353
354 def test_compare_entry_1(self):
355 dn = 'cn=user4,ou=test,o=lab'
356 self.connection_1.bind()
357 result = self.connection_1.compare(dn, 'sn', 'user4_sn')
358 if not self.connection_1.strategy.sync:
359 _, result = self.connection_1.get_response(result)
360 else:
361 result = self.connection_1.result
362 self.assertTrue(result['description'], 'compareTrue')
363 result = self.connection_1.compare(dn, 'sn', 'bad_sn')
364 if not self.connection_1.strategy.sync:
365 _, result = self.connection_1.get_response(result)
366 else:
367 result = self.connection_1.result
368 self.assertTrue(result['description'], 'compareFalse')
369
370 def test_compare_entry_2(self):
371 dn = 'cn=user4,ou=test,o=lab'
372 self.connection_2.bind()
373 result = self.connection_2.compare(dn, 'sn', 'user4_sn')
374 if not self.connection_2.strategy.sync:
375 _, result = self.connection_2.get_response(result)
376 else:
377 result = self.connection_2.result
378 self.assertTrue(result['description'], 'compareTrue')
379 result = self.connection_2.compare(dn, 'sn', 'bad_sn')
380 if not self.connection_2.strategy.sync:
381 _, result = self.connection_2.get_response(result)
382 else:
383 result = self.connection_2.result
384 self.assertTrue(result['description'], 'compareFalse')
385
386 def test_compare_entry_3(self):
387 dn = 'cn=user4,ou=test,o=lab'
388 self.connection_3.bind()
389 result = self.connection_3.compare(dn, 'sn', 'user4_sn')
390 if not self.connection_3.strategy.sync:
391 _, result = self.connection_3.get_response(result)
392 else:
393 result = self.connection_3.result
394 self.assertTrue(result['description'], 'compareTrue')
395 result = self.connection_3.compare(dn, 'sn', 'bad_sn')
396 if not self.connection_3.strategy.sync:
397 _, result = self.connection_3.get_response(result)
398 else:
399 result = self.connection_3.result
400 self.assertTrue(result['description'], 'compareFalse')
401
402 def test_move_dn_1(self):
403 dn = 'cn=user4,ou=test,o=lab'
404 self.connection_1.bind()
405 result = self.connection_1.modify_dn(dn, relative_dn='cn=user4', new_superior='ou=moved,o=lab')
406 if not self.connection_1.strategy.sync:
407 _, result = self.connection_1.get_response(result)
408 else:
409 result = self.connection_1.result
410 self.assertTrue(result['description'], 'success')
411 self.assertTrue('cn=user4,ou=moved,o=lab' in self.connection_1.strategy.entries)
412 self.assertFalse(dn in self.connection_1.strategy.entries)
413
414 def test_move_dn_2(self):
415 dn = 'cn=user4,ou=test,o=lab'
416 self.connection_2.bind()
417 result = self.connection_2.modify_dn(dn, relative_dn='cn=user4', new_superior='ou=moved,o=lab')
418 if not self.connection_2.strategy.sync:
419 _, result = self.connection_2.get_response(result)
420 else:
421 result = self.connection_2.result
422 self.assertTrue(result['description'], 'success')
423 self.assertTrue('cn=user4,ou=moved,o=lab' in self.connection_2.strategy.entries)
424 self.assertFalse(dn in self.connection_2.strategy.entries)
425
426 def test_move_dn_3(self):
427 dn = 'cn=user4,ou=test,o=lab'
428 self.connection_3.bind()
429 result = self.connection_3.modify_dn(dn, relative_dn='cn=user4', new_superior='ou=moved,o=lab')
430 if not self.connection_3.strategy.sync:
431 _, result = self.connection_3.get_response(result)
432 else:
433 result = self.connection_3.result
434 self.assertTrue(result['description'], 'success')
435 self.assertTrue('cn=user4,ou=moved,o=lab' in self.connection_3.strategy.entries)
436 self.assertFalse(dn in self.connection_3.strategy.entries)
437
438 def test_rename_dn_1(self):
439 dn = 'cn=user4,ou=test,o=lab'
440 self.connection_1.bind()
441 result = self.connection_1.modify_dn(dn, relative_dn='cn=user_renamed')
442 if not self.connection_1.strategy.sync:
443 _, result = self.connection_1.get_response(result)
444 else:
445 result = self.connection_1.result
446 self.assertTrue(result['description'], 'success')
447 self.assertTrue('cn=user_renamed,ou=test,o=lab' in self.connection_1.strategy.entries)
448 self.assertFalse(dn in self.connection_1.strategy.entries)
449
450 def test_rename_dn_2(self):
451 dn = 'cn=user4,ou=test,o=lab'
452 self.connection_2.bind()
453 result = self.connection_2.modify_dn(dn, relative_dn='cn=user_renamed')
454 if not self.connection_2.strategy.sync:
455 _, result = self.connection_2.get_response(result)
456 else:
457 result = self.connection_2.result
458 self.assertTrue(result['description'], 'success')
459 self.assertTrue('cn=user_renamed,ou=test,o=lab' in self.connection_2.strategy.entries)
460 self.assertFalse(dn in self.connection_2.strategy.entries)
461
462 def test_rename_dn_3(self):
463 dn = 'cn=user4,ou=test,o=lab'
464 self.connection_3.bind()
465 result = self.connection_3.modify_dn(dn, relative_dn='cn=user_renamed')
466 if not self.connection_3.strategy.sync:
467 _, result = self.connection_3.get_response(result)
468 else:
469 result = self.connection_3.result
470 self.assertTrue(result['description'], 'success')
471 self.assertTrue('cn=user_renamed,ou=test,o=lab' in self.connection_3.strategy.entries)
472 self.assertFalse(dn in self.connection_3.strategy.entries)
473
474 def test_modify_add_existing_singlevalue_1(self):
475 dn = 'cn=user4,ou=test,o=lab'
476 self.connection_1.bind()
477 result = self.connection_1.modify(dn, {'sn': (MODIFY_ADD, ['sn_added'])})
478 if not self.connection_1.strategy.sync:
479 _, result = self.connection_1.get_response(result)
480 else:
481 result = self.connection_1.result
482 self.assertTrue(result['description'], 'success')
483 self.assertTrue(b'sn_added' in self.connection_1.strategy.entries[dn]['sn'])
484
485 def test_modify_add_existing_singlevalue_2(self):
486 dn = 'cn=user4,ou=test,o=lab'
487 self.connection_2.bind()
488 result = self.connection_2.modify(dn, {'sn': (MODIFY_ADD, ['sn_added'])})
489 if not self.connection_2.strategy.sync:
490 _, result = self.connection_2.get_response(result)
491 else:
492 result = self.connection_2.result
493 self.assertTrue(result['description'], 'success')
494 self.assertTrue(b'sn_added' in self.connection_2.strategy.entries[dn]['sn'])
495
496 def test_modify_add_existing_singlevalue_3(self):
497 dn = 'cn=user4,ou=test,o=lab'
498 self.connection_3.bind()
499 result = self.connection_3.modify(dn, {'sn': (MODIFY_ADD, ['sn_added'])})
500 if not self.connection_3.strategy.sync:
501 _, result = self.connection_3.get_response(result)
502 else:
503 result = self.connection_3.result
504 self.assertTrue(result['description'], 'success')
505 self.assertTrue(b'sn_added' in self.connection_3.strategy.entries[dn]['sn'])
506
507 def test_modify_add_nonexisting_singlevalue_1(self):
508 dn = 'cn=user4,ou=test,o=lab'
509 self.connection_1.bind()
510 result = self.connection_1.modify(dn, {'title': (MODIFY_ADD, ['title_added'])})
511 if not self.connection_1.strategy.sync:
512 _, result = self.connection_1.get_response(result)
513 else:
514 result = self.connection_1.result
515 self.assertTrue(result['description'], 'success')
516 self.assertTrue(b'title_added' in self.connection_1.strategy.entries[dn]['title'])
517
518 def test_modify_add_nonexisting_singlevalue_2(self):
519 dn = 'cn=user4,ou=test,o=lab'
520 self.connection_2.bind()
521 result = self.connection_2.modify(dn, {'title': (MODIFY_ADD, ['title_added'])})
522 if not self.connection_2.strategy.sync:
523 _, result = self.connection_2.get_response(result)
524 else:
525 result = self.connection_2.result
526 self.assertTrue(result['description'], 'success')
527 self.assertTrue(b'title_added' in self.connection_2.strategy.entries[dn]['title'])
528
529 def test_modify_add_nonexisting_singlevalue_3(self):
530 dn = 'cn=user4,ou=test,o=lab'
531 self.connection_3.bind()
532 result = self.connection_3.modify(dn, {'title': (MODIFY_ADD, ['title_added'])})
533 if not self.connection_3.strategy.sync:
534 _, result = self.connection_3.get_response(result)
535 else:
536 result = self.connection_3.result
537 self.assertTrue(result['description'], 'success')
538 self.assertTrue(b'title_added' in self.connection_3.strategy.entries[dn]['title'])
539
540 def test_modify_add_existing_multivalue_1(self):
541 dn = 'cn=user4,ou=test,o=lab'
542 self.connection_1.bind()
543 result = self.connection_1.modify(dn, {'sn': (MODIFY_ADD, ['sn_added1', 'sn_added2'])})
544 if not self.connection_1.strategy.sync:
545 _, result = self.connection_1.get_response(result)
546 else:
547 result = self.connection_1.result
548 self.assertTrue(result['description'], 'success')
549 self.assertTrue(b'sn_added1' in self.connection_1.strategy.entries[dn]['sn'])
550 self.assertTrue(b'sn_added2' in self.connection_1.strategy.entries[dn]['sn'])
551
552 def test_modify_add_existing_multivalue_2(self):
553 dn = 'cn=user4,ou=test,o=lab'
554 self.connection_2.bind()
555 result = self.connection_2.modify(dn, {'sn': (MODIFY_ADD, ['sn_added1', 'sn_added2'])})
556 if not self.connection_2.strategy.sync:
557 _, result = self.connection_2.get_response(result)
558 else:
559 result = self.connection_2.result
560 self.assertTrue(result['description'], 'success')
561 self.assertTrue(b'sn_added1' in self.connection_2.strategy.entries[dn]['sn'])
562 self.assertTrue(b'sn_added2' in self.connection_2.strategy.entries[dn]['sn'])
563
564 def test_modify_add_existing_multivalue_3(self):
565 dn = 'cn=user4,ou=test,o=lab'
566 self.connection_3.bind()
567 result = self.connection_3.modify(dn, {'sn': (MODIFY_ADD, ['sn_added1', 'sn_added2'])})
568 if not self.connection_3.strategy.sync:
569 _, result = self.connection_3.get_response(result)
570 else:
571 result = self.connection_3.result
572 self.assertTrue(result['description'], 'success')
573 self.assertTrue(b'sn_added1' in self.connection_3.strategy.entries[dn]['sn'])
574 self.assertTrue(b'sn_added2' in self.connection_3.strategy.entries[dn]['sn'])
575
576 def test_modify_add_nonexisting_multivalue_1(self):
577 dn = 'cn=user4,ou=test,o=lab'
578 self.connection_1.bind()
579 result = self.connection_1.modify(dn, {'title': (MODIFY_ADD, ['title_added1', 'title_added2'])})
580 if not self.connection_1.strategy.sync:
581 _, result = self.connection_1.get_response(result)
582 else:
583 result = self.connection_1.result
584 self.assertTrue(result['description'], 'success')
585 self.assertTrue(b'title_added1' in self.connection_1.strategy.entries[dn]['title'])
586 self.assertTrue(b'title_added2' in self.connection_1.strategy.entries[dn]['title'])
587
588 def test_modify_add_nonexisting_multivalue_2(self):
589 dn = 'cn=user4,ou=test,o=lab'
590 self.connection_2.bind()
591 result = self.connection_2.modify(dn, {'title': (MODIFY_ADD, ['title_added1', 'title_added2'])})
592 if not self.connection_2.strategy.sync:
593 _, result = self.connection_2.get_response(result)
594 else:
595 result = self.connection_2.result
596 self.assertTrue(result['description'], 'success')
597 self.assertTrue(b'title_added1' in self.connection_2.strategy.entries[dn]['title'])
598 self.assertTrue(b'title_added2' in self.connection_2.strategy.entries[dn]['title'])
599
600 def test_modify_add_nonexisting_multivalue_3(self):
601 dn = 'cn=user4,ou=test,o=lab'
602 self.connection_3.bind()
603 result = self.connection_3.modify(dn, {'title': (MODIFY_ADD, ['title_added1', 'title_added2'])})
604 if not self.connection_3.strategy.sync:
605 _, result = self.connection_3.get_response(result)
606 else:
607 result = self.connection_3.result
608 self.assertTrue(result['description'], 'success')
609 self.assertTrue(b'title_added1' in self.connection_3.strategy.entries[dn]['title'])
610 self.assertTrue(b'title_added2' in self.connection_3.strategy.entries[dn]['title'])
611
612 def test_modify_delete_nonexisting_attribute_1(self):
613 dn = 'cn=user4,ou=test,o=lab'
614 self.connection_1.bind()
615 result = self.connection_1.modify(dn, {'initials': (MODIFY_DELETE, ['initials1', 'initials2'])})
616 if not self.connection_1.strategy.sync:
617 _, result = self.connection_1.get_response(result)
618 else:
619 result = self.connection_1.result
620 self.assertEqual(result['description'], 'noSuchAttribute')
621
622 def test_modify_delete_nonexisting_attribute_2(self):
623 dn = 'cn=user4,ou=test,o=lab'
624 self.connection_2.bind()
625 result = self.connection_2.modify(dn, {'initials': (MODIFY_DELETE, ['initials1', 'initials2'])})
626 if not self.connection_2.strategy.sync:
627 _, result = self.connection_2.get_response(result)
628 else:
629 result = self.connection_2.result
630 self.assertEqual(result['description'], 'noSuchAttribute')
631
632 def test_modify_delete_nonexisting_attribute_3(self):
633 dn = 'cn=user4,ou=test,o=lab'
634 self.connection_3.bind()
635 result = self.connection_3.modify(dn, {'initials': (MODIFY_DELETE, ['initials1', 'initials2'])})
636 if not self.connection_3.strategy.sync:
637 _, result = self.connection_3.get_response(result)
638 else:
639 result = self.connection_3.result
640 self.assertEqual(result['description'], 'noSuchAttribute')
641
642 def test_modify_delete_existing_singlevalue_1(self):
643 dn = 'cn=user4,ou=test,o=lab'
644 self.connection_1.bind()
645 result = self.connection_1.modify(dn, {'title': (MODIFY_DELETE, ['title1'])})
646 if not self.connection_1.strategy.sync:
647 _, result = self.connection_1.get_response(result)
648 else:
649 result = self.connection_1.result
650 self.assertEqual(result['description'], 'success')
651
652 def test_modify_delete_existing_singlevalue_2(self):
653 dn = 'cn=user4,ou=test,o=lab'
654 self.connection_2.bind()
655 result = self.connection_2.modify(dn, {'sn': (MODIFY_DELETE, ['user4_sn'])})
656 if not self.connection_2.strategy.sync:
657 _, result = self.connection_2.get_response(result)
658 else:
659 result = self.connection_2.result
660 self.assertEqual(result['description'], 'success')
661
662 def test_modify_delete_existing_singlevalue_3(self):
663 dn = 'cn=user4,ou=test,o=lab'
664 self.connection_3.bind()
665 result = self.connection_3.modify(dn, {'sn': (MODIFY_DELETE, ['user4_sn'])})
666 if not self.connection_3.strategy.sync:
667 _, result = self.connection_3.get_response(result)
668 else:
669 result = self.connection_3.result
670 self.assertEqual(result['description'], 'success')
671
672 def test_modify_delete_existing_multivalue_1(self):
673 dn = 'cn=user4,ou=test,o=lab'
674 self.connection_1.bind()
675 result = self.connection_1.modify(dn, {'title': (MODIFY_DELETE, ['title1', 'title2'])})
676 if not self.connection_1.strategy.sync:
677 _, result = self.connection_1.get_response(result)
678 else:
679 result = self.connection_1.result
680 self.assertEqual(result['description'], 'success')
681 self.assertTrue(self.connection_1.strategy.entries[dn]['title'] == [b'title3'])
682
683 def test_modify_delete_existing_multivalue_2(self):
684 dn = 'cn=user4,ou=test,o=lab'
685 self.connection_2.bind()
686 result = self.connection_2.modify(dn, {'title': (MODIFY_DELETE, ['title1', 'title2'])})
687 if not self.connection_2.strategy.sync:
688 _, result = self.connection_2.get_response(result)
689 else:
690 result = self.connection_2.result
691 self.assertEqual(result['description'], 'success')
692 self.assertTrue(self.connection_2.strategy.entries[dn]['title'] == [b'title3'])
693
694 def test_modify_delete_existing_multivalue_3(self):
695 dn = 'cn=user4,ou=test,o=lab'
696 self.connection_3.bind()
697 result = self.connection_3.modify(dn, {'title': (MODIFY_DELETE, ['title1', 'title2'])})
698 if not self.connection_3.strategy.sync:
699 _, result = self.connection_3.get_response(result)
700 else:
701 result = self.connection_3.result
702 self.assertEqual(result['description'], 'success')
703 self.assertTrue(self.connection_3.strategy.entries[dn]['title'] == [b'title3'])
704
705 def test_modify_replace_existing_singlevalue_1(self):
706 dn = 'cn=user4,ou=test,o=lab'
707 self.connection_1.bind()
708 result = self.connection_1.modify(dn, {'sn': (MODIFY_REPLACE, ['user_test_sn'])})
709 if not self.connection_1.strategy.sync:
710 _, result = self.connection_1.get_response(result)
711 else:
712 result = self.connection_1.result
713 self.assertEqual(result['description'], 'success')
714 self.assertTrue(b'user_test_sn' in self.connection_1.strategy.entries[dn]['sn'])
715 self.assertEqual(len(self.connection_1.strategy.entries[dn]['sn']), 1)
716
717 def test_modify_replace_existing_singlevalue_2(self):
718 dn = 'cn=user4,ou=test,o=lab'
719 self.connection_2.bind()
720 result = self.connection_2.modify(dn, {'sn': (MODIFY_REPLACE, ['user_test_sn'])})
721 if not self.connection_2.strategy.sync:
722 _, result = self.connection_2.get_response(result)
723 else:
724 result = self.connection_2.result
725 self.assertEqual(result['description'], 'success')
726 self.assertTrue(b'user_test_sn' in self.connection_2.strategy.entries[dn]['sn'])
727 self.assertEqual(len(self.connection_2.strategy.entries[dn]['sn']), 1)
728
729 def test_modify_replace_existing_singlevalue_3(self):
730 dn = 'cn=user4,ou=test,o=lab'
731 self.connection_3.bind()
732 result = self.connection_3.modify(dn, {'sn': (MODIFY_REPLACE, ['user_test_sn'])})
733 if not self.connection_3.strategy.sync:
734 _, result = self.connection_3.get_response(result)
735 else:
736 result = self.connection_3.result
737 self.assertEqual(result['description'], 'success')
738 self.assertTrue(b'user_test_sn' in self.connection_3.strategy.entries[dn]['sn'])
739 self.assertEqual(len(self.connection_3.strategy.entries[dn]['sn']), 1)
740
741 def test_modify_replace_existing_multivalue_1(self):
742 dn = 'cn=user4,ou=test,o=lab'
743 self.connection_1.bind()
744 result = self.connection_1.modify(dn, {'title': (MODIFY_REPLACE, ['title4', 'title5'])})
745 if not self.connection_1.strategy.sync:
746 _, result = self.connection_1.get_response(result)
747 else:
748 result = self.connection_1.result
749 self.assertEqual(result['description'], 'success')
750 self.assertFalse(b'title1' in self.connection_1.strategy.entries[dn]['title'])
751 self.assertFalse(b'title2' in self.connection_1.strategy.entries[dn]['title'])
752 self.assertFalse(b'title3' in self.connection_1.strategy.entries[dn]['title'])
753 self.assertTrue(b'title4' in self.connection_1.strategy.entries[dn]['title'])
754 self.assertTrue(b'title5' in self.connection_1.strategy.entries[dn]['title'])
755 self.assertEqual(len(self.connection_1.strategy.entries[dn]['title']), 2)
756
757 def test_modify_replace_existing_multivalue_2(self):
758 dn = 'cn=user4,ou=test,o=lab'
759 self.connection_2.bind()
760 result = self.connection_2.modify(dn, {'title': (MODIFY_REPLACE, ['title4', 'title5'])})
761 if not self.connection_2.strategy.sync:
762 _, result = self.connection_2.get_response(result)
763 else:
764 result = self.connection_2.result
765 self.assertEqual(result['description'], 'success')
766 self.assertFalse(b'title1' in self.connection_2.strategy.entries[dn]['title'])
767 self.assertFalse(b'title2' in self.connection_2.strategy.entries[dn]['title'])
768 self.assertFalse(b'title3' in self.connection_2.strategy.entries[dn]['title'])
769 self.assertTrue(b'title4' in self.connection_2.strategy.entries[dn]['title'])
770 self.assertTrue(b'title5' in self.connection_2.strategy.entries[dn]['title'])
771 self.assertEqual(len(self.connection_2.strategy.entries[dn]['title']), 2)
772
773 def test_modify_replace_existing_multivalue_3(self):
774 dn = 'cn=user4,ou=test,o=lab'
775 self.connection_3.bind()
776 result = self.connection_3.modify(dn, {'title': (MODIFY_REPLACE, ['title4', 'title5'])})
777 if not self.connection_3.strategy.sync:
778 _, result = self.connection_3.get_response(result)
779 else:
780 result = self.connection_3.result
781 self.assertEqual(result['description'], 'success')
782 self.assertFalse(b'title1' in self.connection_3.strategy.entries[dn]['title'])
783 self.assertFalse(b'title2' in self.connection_3.strategy.entries[dn]['title'])
784 self.assertFalse(b'title3' in self.connection_3.strategy.entries[dn]['title'])
785 self.assertTrue(b'title4' in self.connection_3.strategy.entries[dn]['title'])
786 self.assertTrue(b'title5' in self.connection_3.strategy.entries[dn]['title'])
787 self.assertEqual(len(self.connection_3.strategy.entries[dn]['title']), 2)
788
789 def test_modify_replace_existing_novalue_1(self):
790 dn = 'cn=user4,ou=test,o=lab'
791 self.connection_1.bind()
792 result = self.connection_1.modify(dn, {'title': (MODIFY_REPLACE, [])})
793 if not self.connection_1.strategy.sync:
794 _, result = self.connection_1.get_response(result)
795 else:
796 result = self.connection_1.result
797 self.assertEqual(result['description'], 'success')
798 self.assertFalse(b'title' in self.connection_1.strategy.entries[dn])
799
800 def test_modify_replace_existing_novalue_2(self):
801 dn = 'cn=user4,ou=test,o=lab'
802 self.connection_2.bind()
803 result = self.connection_2.modify(dn, {'title': (MODIFY_REPLACE, [])})
804 if not self.connection_2.strategy.sync:
805 _, result = self.connection_2.get_response(result)
806 else:
807 result = self.connection_2.result
808 self.assertEqual(result['description'], 'success')
809 self.assertFalse(b'title' in self.connection_2.strategy.entries[dn])
810
811 def test_modify_replace_existing_novalue_3(self):
812 dn = 'cn=user4,ou=test,o=lab'
813 self.connection_3.bind()
814 result = self.connection_3.modify(dn, {'title': (MODIFY_REPLACE, [])})
815 if not self.connection_3.strategy.sync:
816 _, result = self.connection_3.get_response(result)
817 else:
818 result = self.connection_3.result
819 self.assertEqual(result['description'], 'success')
820 self.assertFalse(b'title' in self.connection_3.strategy.entries[dn])
821
822 def test_modify_replace_not_existing_novalue_1(self):
823 dn = 'cn=user4,ou=test,o=lab'
824 self.connection_1.bind()
825 result = self.connection_1.modify(dn, {'initials': (MODIFY_REPLACE, [])})
826 if not self.connection_1.strategy.sync:
827 _, result = self.connection_1.get_response(result)
828 else:
829 result = self.connection_1.result
830 self.assertEqual(result['description'], 'success')
831 self.assertFalse(b'initials' in self.connection_1.strategy.entries[dn])
832
833 def test_modify_replace_not_existing_novalue_2(self):
834 dn = 'cn=user4,ou=test,o=lab'
835 self.connection_2.bind()
836 result = self.connection_2.modify(dn, {'initials': (MODIFY_REPLACE, [])})
837 if not self.connection_2.strategy.sync:
838 _, result = self.connection_2.get_response(result)
839 else:
840 result = self.connection_2.result
841 self.assertEqual(result['description'], 'success')
842 self.assertFalse(b'initials' in self.connection_2.strategy.entries[dn])
843
844 def test_modify_replace_not_existing_novalue_3(self):
845 dn = 'cn=user4,ou=test,o=lab'
846 self.connection_3.bind()
847 result = self.connection_3.modify(dn, {'initials': (MODIFY_REPLACE, [])})
848 if not self.connection_3.strategy.sync:
849 _, result = self.connection_3.get_response(result)
850 else:
851 result = self.connection_3.result
852 self.assertEqual(result['description'], 'success')
853 self.assertFalse(b'initials' in self.connection_3.strategy.entries[dn])
854
855 def test_modify_replace_not_existing_singlevalue_1(self):
856 dn = 'cn=user4,ou=test,o=lab'
857 self.connection_1.bind()
858 result = self.connection_1.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1'])})
859 if not self.connection_1.strategy.sync:
860 _, result = self.connection_1.get_response(result)
861 else:
862 result = self.connection_1.result
863 self.assertEqual(result['description'], 'success')
864 self.assertTrue(b'initials1' in self.connection_1.strategy.entries[dn]['initials'])
865
866 def test_modify_replace_not_existing_singlevalue_2(self):
867 dn = 'cn=user4,ou=test,o=lab'
868 self.connection_2.bind()
869 result = self.connection_2.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1'])})
870 if not self.connection_2.strategy.sync:
871 _, result = self.connection_2.get_response(result)
872 else:
873 result = self.connection_2.result
874 self.assertEqual(result['description'], 'success')
875 self.assertTrue(b'initials1' in self.connection_2.strategy.entries[dn]['initials'])
876
877 def test_modify_replace_not_existing_singlevalue_3(self):
878 dn = 'cn=user4,ou=test,o=lab'
879 self.connection_3.bind()
880 result = self.connection_3.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1'])})
881 if not self.connection_3.strategy.sync:
882 _, result = self.connection_3.get_response(result)
883 else:
884 result = self.connection_3.result
885 self.assertEqual(result['description'], 'success')
886 self.assertTrue(b'initials1' in self.connection_3.strategy.entries[dn]['initials'])
887
888 def test_modify_replace_not_existing_multivalue_1(self):
889 dn = 'cn=user4,ou=test,o=lab'
890 self.connection_1.bind()
891 result = self.connection_1.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1', 'initials2'])})
892 if not self.connection_1.strategy.sync:
893 _, result = self.connection_1.get_response(result)
894 else:
895 result = self.connection_1.result
896 self.assertEqual(result['description'], 'success')
897 self.assertTrue(b'initials1' in self.connection_1.strategy.entries[dn]['initials'])
898 self.assertTrue(b'initials2' in self.connection_1.strategy.entries[dn]['initials'])
899
900 def test_modify_replace_not_existing_multivalue_2(self):
901 dn = 'cn=user4,ou=test,o=lab'
902 self.connection_2.bind()
903 result = self.connection_2.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1', 'initials2'])})
904 if not self.connection_2.strategy.sync:
905 _, result = self.connection_2.get_response(result)
906 else:
907 result = self.connection_2.result
908 self.assertEqual(result['description'], 'success')
909 self.assertTrue(b'initials1' in self.connection_2.strategy.entries[dn]['initials'])
910 self.assertTrue(b'initials2' in self.connection_2.strategy.entries[dn]['initials'])
911
912 def test_modify_replace_not_existing_multivalue_3(self):
913 dn = 'cn=user4,ou=test,o=lab'
914 self.connection_3.bind()
915 result = self.connection_3.modify(dn, {'initials': (MODIFY_REPLACE, ['initials1', 'initials2'])})
916 if not self.connection_3.strategy.sync:
917 _, result = self.connection_3.get_response(result)
918 else:
919 result = self.connection_3.result
920 self.assertEqual(result['description'], 'success')
921 self.assertTrue(b'initials1' in self.connection_3.strategy.entries[dn]['initials'])
922 self.assertTrue(b'initials2' in self.connection_3.strategy.entries[dn]['initials'])
923
924 def test_search_exact_match_single_attribute_1(self):
925 self.connection_1.bind()
926 result = self.connection_1.search('o=lab', '(cn=user1)', search_scope=SUBTREE, attributes=['cn', 'sn'])
927 response = self.connection_1.response
928 if not self.connection_1.strategy.sync:
929 response, result = self.connection_1.get_response(result)
930 else:
931 result = self.connection_1.result
932 self.assertEqual(result['description'], 'success')
933 self.assertEqual('user1', response[0]['attributes']['cn'][0])
934
935 def test_search_exact_match_single_attribute_2(self):
936 self.connection_2.bind()
937 result = self.connection_2.search('o=lab', '(cn=user2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
938 response = self.connection_2.response
939 if not self.connection_2.strategy.sync:
940 response, result = self.connection_2.get_response(result)
941 else:
942 result = self.connection_2.result
943 self.assertEqual(result['description'], 'success')
944 self.assertEqual('user2', response[0]['attributes']['cn'][0])
945
946 def test_search_exact_match_single_attribute_3(self):
947 self.connection_3.bind()
948 result = self.connection_3.search('o=lab', '(cn=user3)', search_scope=SUBTREE, attributes=['cn', 'sn'])
949 response = self.connection_3.response
950 if not self.connection_3.strategy.sync:
951 response, result = self.connection_3.get_response(result)
952 else:
953 result = self.connection_3.result
954 self.assertEqual(result['description'], 'success')
955 self.assertEqual('user3', response[0]['attributes']['cn'][0])
956
957 def test_search_exact_match_single_binary_attribute_1(self):
958 self.connection_1.bind()
959 result = self.connection_1.search('o=lab', '(guid=07039e68-4373-264d-a0a7-111111111111)', search_scope=SUBTREE, attributes=['cn', 'guid'])
960 response = self.connection_1.response
961 if not self.connection_1.strategy.sync:
962 response, result = self.connection_1.get_response(result)
963 else:
964 result = self.connection_1.result
965 self.assertEqual(result['description'], 'success')
966 self.assertEqual('user1', response[0]['attributes']['cn'][0])
967 self.assertEqual('07039e68-4373-264d-a0a7-111111111111', response[0]['attributes']['guid'])
968
969 def test_search_exact_match_single_binary_attribute_2(self):
970 self.connection_2.bind()
971 result = self.connection_2.search('o=lab', '(guid=07039e68-4373-264d-a0a7-222222222222)', search_scope=SUBTREE, attributes=['cn', 'guid'])
972 response = self.connection_2.response
973 if not self.connection_2.strategy.sync:
974 response, result = self.connection_2.get_response(result)
975 else:
976 result = self.connection_2.result
977 self.assertEqual(result['description'], 'success')
978 self.assertEqual('user2', response[0]['attributes']['cn'][0])
979 self.assertEqual('07039e68-4373-264d-a0a7-222222222222', response[0]['attributes']['guid'])
980
981 def test_search_exact_match_single_binary_attribute_3(self):
982 self.connection_3.bind()
983 result = self.connection_3.search('o=lab', '(guid=07039e68-4373-264d-a0a7-333333333333)', search_scope=SUBTREE, attributes=['cn', 'guid'])
984 response = self.connection_3.response
985 if not self.connection_3.strategy.sync:
986 response, result = self.connection_3.get_response(result)
987 else:
988 result = self.connection_3.result
989 self.assertEqual(result['description'], 'success')
990 self.assertEqual('user3', response[0]['attributes']['cn'][0])
991 self.assertEqual('07039e68-4373-264d-a0a7-333333333333', response[0]['attributes']['guid'][0])
992
993 def test_search_exact_match_case_insensitive_single_attribute_1(self):
994 self.connection_1.bind()
995 result = self.connection_1.search('o=lab', '(cn=UsEr1)', search_scope=SUBTREE, attributes=['cn', 'sn'])
996 response = self.connection_1.response
997 if not self.connection_1.strategy.sync:
998 response, result = self.connection_1.get_response(result)
999 else:
1000 result = self.connection_1.result
1001 self.assertEqual(result['description'], 'success')
1002 self.assertEqual('user1', response[0]['attributes']['cn'][0])
1003
1004 def test_search_exact_match_case_insensitive_single_attribute_2(self):
1005 self.connection_2.bind()
1006 result = self.connection_2.search('o=lab', '(cn=UsEr2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1007 response = self.connection_2.response
1008 if not self.connection_2.strategy.sync:
1009 response, result = self.connection_2.get_response(result)
1010 else:
1011 result = self.connection_2.result
1012 self.assertEqual(result['description'], 'success')
1013 self.assertEqual('user2', response[0]['attributes']['cn'][0])
1014
1015 def test_search_exact_match_case_insensitive_single_attribute_3(self):
1016 self.connection_3.bind()
1017 result = self.connection_3.search('o=lab', '(cn=UsEr3)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1018 response = self.connection_3.response
1019 if not self.connection_3.strategy.sync:
1020 response, result = self.connection_3.get_response(result)
1021 else:
1022 result = self.connection_3.result
1023 self.assertEqual(result['description'], 'success')
1024 self.assertEqual('user3', response[0]['attributes']['cn'][0])
1025
1026 def test_search_presence_single_attribute_1(self):
1027 self.connection_1.bind()
1028 result = self.connection_1.search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1029 response = self.connection_1.response
1030 if not self.connection_1.strategy.sync:
1031 response, result = self.connection_1.get_response(result)
1032 else:
1033 result = self.connection_1.result
1034 self.assertEqual(result['description'], 'success')
1035 self.assertTrue('user' in response[0]['attributes']['cn'][0])
1036
1037 def test_search_presence_single_attribute_2(self):
1038 self.connection_2.bind()
1039 result = self.connection_2.search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1040 response = self.connection_2.response
1041 if not self.connection_2.strategy.sync:
1042 response, result = self.connection_2.get_response(result)
1043 else:
1044 result = self.connection_2.result
1045 self.assertEqual(result['description'], 'success')
1046 self.assertTrue('user' in response[0]['attributes']['cn'][0])
1047
1048 def test_search_presence_single_attribute_3(self):
1049 self.connection_3.bind()
1050 result = self.connection_3.search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1051 response = self.connection_3.response
1052 if not self.connection_3.strategy.sync:
1053 response, result = self.connection_3.get_response(result)
1054 else:
1055 result = self.connection_3.result
1056 self.assertEqual(result['description'], 'success')
1057 self.assertTrue('user' in response[0]['attributes']['cn'][0])
1058
1059 def test_search_presence_and_filter_1(self):
1060 self.connection_1.bind()
1061 result = self.connection_1.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1062 response = self.connection_1.response
1063 if not self.connection_1.strategy.sync:
1064 response, result = self.connection_1.get_response(result)
1065 else:
1066 result = self.connection_1.result
1067 self.assertEqual(result['description'], 'success')
1068 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1069
1070 self.connection_1b.bind()
1071 result = self.connection_1b.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1072 response = self.connection_1b.response
1073 if not self.connection_1b.strategy.sync:
1074 response, result = self.connection_1b.get_response(result)
1075 else:
1076 result = self.connection_1b.result
1077 self.assertEqual(result['description'], 'success')
1078 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1079
1080 def test_search_presence_and_filter_2(self):
1081 self.connection_2.bind()
1082 result = self.connection_2.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1083 response = self.connection_2.response
1084 if not self.connection_2.strategy.sync:
1085 response, result = self.connection_2.get_response(result)
1086 else:
1087 result = self.connection_2.result
1088 self.assertEqual(result['description'], 'success')
1089 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1090
1091 self.connection_2b.bind()
1092 result = self.connection_2b.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1093 response = self.connection_2b.response
1094 if not self.connection_2b.strategy.sync:
1095 response, result = self.connection_2b.get_response(result)
1096 else:
1097 result = self.connection_2b.result
1098 self.assertEqual(result['description'], 'success')
1099 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1100
1101 def test_search_presence_and_filter_3(self):
1102 self.connection_3.bind()
1103 result = self.connection_3.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1104 response = self.connection_3.response
1105 if not self.connection_3.strategy.sync:
1106 response, result = self.connection_3.get_response(result)
1107 else:
1108 result = self.connection_3.result
1109 self.assertEqual(result['description'], 'success')
1110 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1111
1112 self.connection_3b.bind()
1113 result = self.connection_3b.search('o=lab', '(&(cn=*)(|(sn=user0_sn)(sn=user1_sn)))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1114 response = self.connection_3b.response
1115 if not self.connection_3b.strategy.sync:
1116 response, result = self.connection_3b.get_response(result)
1117 else:
1118 result = self.connection_3b.result
1119 self.assertEqual(result['description'], 'success')
1120 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1'])
1121
1122 def test_search_incorrect_base_1(self):
1123 self.connection_1.bind()
1124 result = self.connection_1.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1125 if not self.connection_1.strategy.sync:
1126 _, result = self.connection_1.get_response(result)
1127 else:
1128 result = self.connection_1.result
1129 self.assertEqual(result['description'], 'noSuchObject')
1130
1131 def test_search_incorrect_base_2(self):
1132 self.connection_2.bind()
1133 result = self.connection_2.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1134 if not self.connection_2.strategy.sync:
1135 _, result = self.connection_2.get_response(result)
1136 else:
1137 result = self.connection_2.result
1138 self.assertEqual(result['description'], 'noSuchObject')
1139
1140 def test_search_incorrect_base_3(self):
1141 self.connection_3.bind()
1142 result = self.connection_3.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1143 if not self.connection_3.strategy.sync:
1144 _, result = self.connection_3.get_response(result)
1145 else:
1146 result = self.connection_3.result
1147 self.assertEqual(result['description'], 'noSuchObject')
1148
1149 def test_search_incorrect_base_exception_1(self):
1150 self.connection_1c.bind()
1151 try:
1152 result = self.connection_1c.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1153 self.fail('exception not raised')
1154 except LDAPNoSuchObjectResult:
1155 pass
1156
1157 if not self.connection_1c.strategy.sync:
1158 _, result = self.connection_1c.get_response(result)
1159 else:
1160 result = self.connection_1c.result
1161 self.assertEqual(result['description'], 'noSuchObject')
1162
1163 def test_search_incorrect_base_exception_2(self):
1164 self.connection_2c.bind()
1165 try:
1166 result = self.connection_2c.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1167 self.fail('exception not raised')
1168 except LDAPNoSuchObjectResult:
1169 pass
1170
1171 if not self.connection_2c.strategy.sync:
1172 _, result = self.connection_2c.get_response(result)
1173 else:
1174 result = self.connection_2c.result
1175 self.assertEqual(result['description'], 'noSuchObject')
1176
1177 def test_search_incorrect_base_exception_3(self):
1178 self.connection_3c.bind()
1179 try:
1180 result = self.connection_3c.search('o=nonexistant', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1181 self.fail('exception not raised')
1182 except LDAPNoSuchObjectResult:
1183 pass
1184
1185 if not self.connection_3c.strategy.sync:
1186 _, result = self.connection_3c.get_response(result)
1187 else:
1188 result = self.connection_3c.result
1189 self.assertEqual(result['description'], 'noSuchObject')
1190
1191 def test_search_presence_and_filter_no_entries_found_1(self):
1192 self.connection_1.bind()
1193 result = self.connection_1.search('o=lab', '(&(cn=*)(sn=user_nonexistant))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1194 response = self.connection_1.response
1195 if not self.connection_1.strategy.sync:
1196 response, result = self.connection_1.get_response(result)
1197 else:
1198 result = self.connection_1.result
1199 self.assertEqual(result['description'], 'success')
1200 self.assertEqual(len(response), 0)
1201
1202 def test_search_presence_and_filter_no_entries_found_2(self):
1203 self.connection_2.bind()
1204 result = self.connection_2.search('o=lab', '(&(cn=*)(sn=user_nonexistant))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1205 response = self.connection_2.response
1206 if not self.connection_2.strategy.sync:
1207 response, result = self.connection_2.get_response(result)
1208 else:
1209 result = self.connection_2.result
1210 self.assertEqual(result['description'], 'success')
1211 self.assertEqual(len(response), 0)
1212
1213 def test_search_presence_and_filter_no_entries_found_3(self):
1214 self.connection_3.bind()
1215 result = self.connection_3.search('o=lab', '(&(cn=*)(sn=user_nonexistant))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1216 response = self.connection_3.response
1217 if not self.connection_3.strategy.sync:
1218 response, result = self.connection_3.get_response(result)
1219 else:
1220 result = self.connection_3.result
1221 self.assertEqual(result['description'], 'success')
1222 self.assertEqual(len(response), 0)
1223
1224 def test_search_exact_match_not_filter_1(self):
1225 self.connection_1.bind()
1226 result = self.connection_1.search('o=lab', '(!(sn=user0_sn))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1227 response = self.connection_1.response
1228 if not self.connection_1.strategy.sync:
1229 response, result = self.connection_1.get_response(result)
1230 else:
1231 result = self.connection_1.result
1232 self.assertEqual(result['description'], 'success')
1233 self.assertNotEqual(response[0]['attributes']['cn'][0], 'user0')
1234
1235 def test_search_exact_match_not_filter_2(self):
1236 self.connection_2.bind()
1237 result = self.connection_2.search('o=lab', '(!(sn=user0_sn))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1238 response = self.connection_2.response
1239 if not self.connection_2.strategy.sync:
1240 response, result = self.connection_2.get_response(result)
1241 else:
1242 result = self.connection_2.result
1243 self.assertEqual(result['description'], 'success')
1244 self.assertNotEqual(response[0]['attributes']['cn'][0], 'user0')
1245
1246 def test_search_exact_match_not_filter_3(self):
1247 self.connection_3.bind()
1248 result = self.connection_3.search('o=lab', '(!(sn=user0_sn))', search_scope=SUBTREE, attributes=['cn', 'sn'])
1249 response = self.connection_3.response
1250 if not self.connection_3.strategy.sync:
1251 response, result = self.connection_3.get_response(result)
1252 else:
1253 result = self.connection_3.result
1254 self.assertEqual(result['description'], 'success')
1255 self.assertNotEqual(response[0]['attributes']['cn'][0], 'user0')
1256
1257 def test_search_greater_or_equal_than_string_1(self):
1258 self.connection_1.bind()
1259 result = self.connection_1.search('o=lab', '(userPassword>=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1260 response = self.connection_1.response
1261 if not self.connection_1.strategy.sync:
1262 response, result = self.connection_1.get_response(result)
1263 else:
1264 result = self.connection_1.result
1265 self.assertEqual(result['description'], 'success')
1266 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1267
1268 def test_search_greater_or_equal_than_string_2(self):
1269 self.connection_2.bind()
1270 result = self.connection_2.search('o=lab', '(userPassword>=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1271 response = self.connection_2.response
1272 if not self.connection_2.strategy.sync:
1273 response, result = self.connection_2.get_response(result)
1274 else:
1275 result = self.connection_2.result
1276 self.assertEqual(result['description'], 'success')
1277 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1278
1279 def test_search_greater_or_equal_than_string_3(self):
1280 self.connection_3.bind()
1281 result = self.connection_3.search('o=lab', '(userPassword>=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1282 response = self.connection_3.response
1283 if not self.connection_3.strategy.sync:
1284 response, result = self.connection_3.get_response(result)
1285 else:
1286 result = self.connection_3.result
1287 self.assertEqual(result['description'], 'success')
1288 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1289
1290 def test_search_greater_or_equal_than_int_1(self):
1291 self.connection_1.bind()
1292 result = self.connection_1.search('o=lab', '(revision>=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1293 response = self.connection_1.response
1294 if not self.connection_1.strategy.sync:
1295 response, result = self.connection_1.get_response(result)
1296 else:
1297 result = self.connection_1.result
1298 self.assertEqual(result['description'], 'success')
1299 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1300
1301 def test_search_greater_or_equal_than_int_2(self):
1302 self.connection_2.bind()
1303 result = self.connection_2.search('o=lab', '(revision>=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1304 response = self.connection_2.response
1305 if not self.connection_2.strategy.sync:
1306 response, result = self.connection_2.get_response(result)
1307 else:
1308 result = self.connection_2.result
1309 self.assertEqual(result['description'], 'success')
1310 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1311
1312 def test_search_greater_or_equal_than_int_3(self):
1313 self.connection_3.bind()
1314 result = self.connection_3.search('o=lab', '(revision>=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1315 response = self.connection_3.response
1316 if not self.connection_3.strategy.sync:
1317 response, result = self.connection_3.get_response(result)
1318 else:
1319 result = self.connection_3.result
1320 self.assertEqual(result['description'], 'success')
1321 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2', 'user3', 'user4'])
1322
1323 def test_search_less_or_equal_than_string_1(self):
1324 self.connection_1.bind()
1325 result = self.connection_1.search('o=lab', '(userPassword<=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1326 response = self.connection_1.response
1327 if not self.connection_1.strategy.sync:
1328 response, result = self.connection_1.get_response(result)
1329 else:
1330 result = self.connection_1.result
1331 self.assertEqual(result['description'], 'success')
1332 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1333
1334 def test_search_less_or_equal_than_string_2(self):
1335 self.connection_2.bind()
1336 result = self.connection_2.search('o=lab', '(userPassword<=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1337 response = self.connection_2.response
1338 if not self.connection_2.strategy.sync:
1339 response, result = self.connection_2.get_response(result)
1340 else:
1341 result = self.connection_2.result
1342 self.assertEqual(result['description'], 'success')
1343 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1344
1345 def test_search_less_or_equal_than_string_3(self):
1346 self.connection_3.bind()
1347 result = self.connection_3.search('o=lab', '(userPassword<=test2222)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1348 response = self.connection_3.response
1349 if not self.connection_3.strategy.sync:
1350 response, result = self.connection_3.get_response(result)
1351 else:
1352 result = self.connection_3.result
1353 self.assertEqual(result['description'], 'success')
1354 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1355
1356 def test_search_less_or_equal_than_int_1(self):
1357 self.connection_1.bind()
1358 result = self.connection_1.search('o=lab', '(revision<=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1359 response = self.connection_1.response
1360 if not self.connection_1.strategy.sync:
1361 response, result = self.connection_1.get_response(result)
1362 else:
1363 result = self.connection_1.result
1364 self.assertEqual(result['description'], 'success')
1365 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1366
1367 def test_search_less_or_equal_than_int_2(self):
1368 self.connection_2.bind()
1369 result = self.connection_2.search('o=lab', '(revision<=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1370 response = self.connection_2.response
1371 if not self.connection_2.strategy.sync:
1372 response, result = self.connection_2.get_response(result)
1373 else:
1374 result = self.connection_2.result
1375 self.assertEqual(result['description'], 'success')
1376 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1377
1378 def test_search_less_or_equal_than_int_3(self):
1379 self.connection_3.bind()
1380 result = self.connection_3.search('o=lab', '(revision<=2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1381 response = self.connection_3.response
1382 if not self.connection_3.strategy.sync:
1383 response, result = self.connection_3.get_response(result)
1384 else:
1385 result = self.connection_3.result
1386 self.assertEqual(result['description'], 'success')
1387 self.assertTrue(response[0]['attributes']['cn'][0] in ['user0', 'user1', 'user2'])
1388
1389 def test_search_substring_1(self):
1390 self.connection_1.bind()
1391 result = self.connection_1.search('o=lab', '(cn=*ser*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1392 response = self.connection_1.response
1393 if not self.connection_1.strategy.sync:
1394 response, result = self.connection_1.get_response(result)
1395 else:
1396 result = self.connection_1.result
1397 self.assertEqual(result['description'], 'success')
1398 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1399
1400 def test_search_substring_2(self):
1401 self.connection_2.bind()
1402 result = self.connection_2.search('o=lab', '(cn=*ser*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1403 response = self.connection_2.response
1404 if not self.connection_2.strategy.sync:
1405 response, result = self.connection_2.get_response(result)
1406 else:
1407 result = self.connection_2.result
1408 self.assertEqual(result['description'], 'success')
1409 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1410
1411 def test_search_substring_3(self):
1412 self.connection_3.bind()
1413 result = self.connection_3.search('o=lab', '(cn=*ser*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1414 response = self.connection_3.response
1415 if not self.connection_3.strategy.sync:
1416 response, result = self.connection_3.get_response(result)
1417 else:
1418 result = self.connection_3.result
1419 self.assertEqual(result['description'], 'success')
1420 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1421
1422 def test_search_case_insensitive_substring_1(self):
1423 self.connection_1.bind()
1424 result = self.connection_1.search('o=lab', '(cn=*SeR*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1425 response = self.connection_1.response
1426 if not self.connection_1.strategy.sync:
1427 response, result = self.connection_1.get_response(result)
1428 else:
1429 result = self.connection_1.result
1430 self.assertEqual(result['description'], 'success')
1431 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1432
1433 def test_search_case_insensitive_substring_2(self):
1434 self.connection_2.bind()
1435 result = self.connection_2.search('o=lab', '(cn=*SeR*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1436 response = self.connection_2.response
1437 if not self.connection_2.strategy.sync:
1438 response, result = self.connection_2.get_response(result)
1439 else:
1440 result = self.connection_2.result
1441 self.assertEqual(result['description'], 'success')
1442 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1443
1444 def test_search_case_insensitive_substring_3(self):
1445 self.connection_3.bind()
1446 result = self.connection_3.search('o=lab', '(cn=*SeR*2)', search_scope=SUBTREE, attributes=['cn', 'sn'])
1447 response = self.connection_3.response
1448 if not self.connection_3.strategy.sync:
1449 response, result = self.connection_3.get_response(result)
1450 else:
1451 result = self.connection_3.result
1452 self.assertEqual(result['description'], 'success')
1453 self.assertTrue(response[0]['attributes']['cn'][0] in ['user2'])
1454
1455 def test_search_presence_singlevalue_attribute_1(self):
1456 self.connection_1.bind()
1457 result = self.connection_1.search('o=lab', '(revision=*)', search_scope=SUBTREE, attributes=['cn', 'revision'])
1458 response = self.connection_1.response
1459 if not self.connection_1.strategy.sync:
1460 response, result = self.connection_1.get_response(result)
1461 else:
1462 result = self.connection_1.result
1463 self.assertEqual(result['description'], 'success')
1464
1465 self.assertTrue(isinstance(response[0]['attributes']['revision'], int))
1466
1467 def test_search_presence_singlevalue_attribute_2(self):
1468 self.connection_2.bind()
1469 result = self.connection_2.search('o=lab', '(revision=*)', search_scope=SUBTREE, attributes=['cn', 'revision'])
1470 response = self.connection_2.response
1471 if not self.connection_2.strategy.sync:
1472 response, result = self.connection_2.get_response(result)
1473 else:
1474 result = self.connection_2.result
1475 self.assertEqual(result['description'], 'success')
1476 self.assertTrue(isinstance(response[0]['attributes']['revision'], int))
1477
1478 def test_search_presence_singlevalue_attribute_3(self):
1479 self.connection_3.bind()
1480 result = self.connection_3.search('o=lab', '(revision=*)', search_scope=SUBTREE, attributes=['cn', 'revision'])
1481 response = self.connection_3.response
1482 if not self.connection_3.strategy.sync:
1483 response, result = self.connection_3.get_response(result)
1484 else:
1485 result = self.connection_3.result
1486 self.assertEqual(result['description'], 'success')
1487 self.assertTrue(isinstance(response[0]['attributes']['revision'], list)) # no schema so attributes are returned as lists
1488
1489 def test_search_paged_1(self):
1490 self.connection_1.bind()
1491 response = []
1492 for resp in self.connection_1.extend.standard.paged_search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'revision'], paged_size=2, paged_criticality=True):
1493 response.append(resp)
1494
1495 self.assertEqual(len(response), 5)
1496
1497 def test_search_paged_2(self):
1498 self.connection_2.bind()
1499 response = []
1500 for resp in self.connection_2.extend.standard.paged_search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'revision'], paged_size=2, paged_criticality=True):
1501 response.append(resp)
1502
1503 self.assertEqual(len(response), 5)
1504
1505 def test_search_paged_3(self):
1506 self.connection_3.bind()
1507 response = []
1508 for resp in self.connection_3.extend.standard.paged_search('o=lab', '(cn=*)', search_scope=SUBTREE, attributes=['cn', 'revision'], paged_size=2, paged_criticality=True):
1509 response.append(resp)
1510
1511 self.assertEqual(len(response), 5)