Debian Codegraph @

test/testBytesOperation.py

raw
1 # encoding: utf-8
2 """
3 """
4
5 # Created on 2013.06.06
6 #
7 # Author: Giovanni Cannata
8 #
9 # Copyright 2013 - 2020 Giovanni Cannata
10 #
11 # This file is part of ldap3.
12 #
13 # ldap3 is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU Lesser General Public License as published
15 # by the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # ldap3 is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public License for more details.
22 #
23 # You should have received a copy of the GNU Lesser General Public License
24 # along with ldap3 in the COPYING and COPYING.LESSER files.
25 # If not, see <http://www.gnu.org/licenses/>.
26
27 import unittest
28 from time import sleep
29
30 from ldap3 import MODIFY_REPLACE, MODIFY_ADD, LEVEL, BASE, SEQUENCE_TYPES
31 from test.config import random_id, get_connection, add_user, drop_connection, test_singlevalued_attribute, test_multivalued_attribute, test_base, test_name_attr, get_response_values
32
33 testcase_id = ''
34
35
36 def make_bytes(value, encoding=None):
37 if str is bytes: # python 2
38 if isinstance(value, unicode):
39 return value.encode(encoding)
40 else:
41 return bytes(value)
42 else:
43 if isinstance(value, SEQUENCE_TYPES):
44 return bytes(value)
45 else:
46 return bytes(value, encoding)
47
48
49 def make_bytearray(value, encoding=None):
50 if str is bytes: # python 2
51 if isinstance(value, unicode):
52 return value.encode(encoding)
53 else:
54 return bytearray(value)
55 else:
56 if isinstance(value, SEQUENCE_TYPES):
57 return bytearray(value)
58 else:
59 return bytearray(value, encoding)
60
61
62 class Test(unittest.TestCase):
63 def setUp(self):
64 global testcase_id
65 testcase_id = random_id()
66 self.connection = get_connection()
67 self.delete_at_teardown = []
68
69 def tearDown(self):
70 drop_connection(self.connection, self.delete_at_teardown)
71 self.assertFalse(self.connection.bound)
72
73 def test_add_operation_from_bytes_literal(self):
74 single = b'abc'
75 multi = [b'abc', b'def']
76 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-1', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
77 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
78 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
79 self.assertEqual(len(response), 1)
80 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
81 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
82
83 def test_add_operation_from_bytes(self):
84 single = make_bytes('àèìòù', 'utf-8')
85 multi = [make_bytes('àèì', 'utf-8'), make_bytes('òù', 'utf-8')]
86 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-2', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
87 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
88 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
89 self.assertEqual(len(response), 1)
90 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
91
92 def test_add_operation_from_byte_values(self):
93 if str is not bytes: # integer list to bytes works only in Python 3
94 single = make_bytes([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
95 multi = [make_bytes([195, 160, 195, 168, 195, 172]), make_bytes([195, 178, 195, 185])]
96 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-3', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
97 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
98 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
99 self.assertEqual(len(response), 1)
100 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
101 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
102
103 def test_add_operation_from_unicode_literal(self):
104 single = make_bytes(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
105 multi = [make_bytes(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytes('\u00f2\u00f9', 'utf-8')]
106 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-4', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
107 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
108 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
109 self.assertEqual(len(response), 1)
110 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
111 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
112
113 def test_add_operation_from_unicode_name(self):
114 if str is not bytes: # works only in Python 3
115 single = make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
116 multi = [make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytes('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
117 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-5', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
118 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
119 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
120 self.assertEqual(len(response), 1)
121 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
122 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
123
124 def test_add_operation_from_bytearray(self):
125 single = make_bytearray('àèìòù', 'utf-8')
126 multi = [make_bytearray('àèì', 'utf-8'), make_bytearray('òù', 'utf-8')]
127 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-6', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
128 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
129 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
130 self.assertEqual(len(response), 1)
131 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
132 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
133
134 def test_add_operation_from_bytearray_values(self):
135 single = make_bytearray([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
136 multi = [make_bytearray([195, 160, 195, 168, 195, 172]), make_bytearray([195, 178, 195, 185])]
137 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-7', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
138 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
139 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
140 self.assertEqual(len(response), 1)
141 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
142 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
143
144 def test_add_operation_from_bytearray_unicode_literal(self):
145 single = make_bytearray(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
146 multi = [make_bytearray(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytearray(u'\u00f2\u00f9', 'utf-8')]
147 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-8', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
148 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
149 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
150 self.assertEqual(len(response), 1)
151 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
152 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
153
154 def test_add_operation_from_bytearray_unicode_name(self):
155 if str is not bytes: # works only in python 3
156 single = make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
157 multi = [make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
158 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-9', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
159 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
160 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
161 self.assertEqual(len(response), 1)
162 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
163 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
164
165 def test_compare_true_operation_with_bytes(self):
166 single = make_bytes('àèìòù', 'utf-8')
167 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-10', attributes={test_singlevalued_attribute: single}, test_bytes=True))
168 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
169 result = self.connection.compare(self.delete_at_teardown[0][0], test_singlevalued_attribute, single)
170 if not self.connection.strategy.sync:
171 _, result = self.connection.get_response(result)
172 else:
173 result = self.connection.result
174
175 self.assertEqual(result['description'], 'compareTrue')
176
177 def test_compare_false_operation_with_bytes(self):
178 single = make_bytes('àèìòù', 'utf-8')
179 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-11', attributes={test_singlevalued_attribute: single}, test_bytes=True))
180 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
181 result = self.connection.compare(self.delete_at_teardown[0][0], test_singlevalued_attribute, 'invalid')
182 if not self.connection.strategy.sync:
183 _, result = self.connection.get_response(result)
184 else:
185 result = self.connection.result
186
187 self.assertEqual(result['description'], 'compareFalse')
188
189 def test_modify_operation_from_bytes_literal(self):
190 single = b'abc'
191 multi = [b'abc', b'def']
192 single_mod = b'cba'
193 multi_mod = [b'cba', b'fed']
194 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-12', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
195 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
196 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
197 self.assertEqual(len(response), 1)
198 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
199 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
200 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
201 if not self.connection.strategy.sync:
202 sleep(2)
203 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
204 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
205 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
206
207 def test_modify_operation_from_bytes(self):
208 single = make_bytes('àèìòù', 'utf-8')
209 multi = [make_bytes('àèì', 'utf-8'), make_bytes('òù', 'utf-8')]
210 single_mod = make_bytes('ùòìèà', 'utf-8')
211 multi_mod = [make_bytes('ìèà', 'utf-8'), make_bytes('ùò', 'utf-8')]
212 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-12', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
213 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
214 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
215 self.assertEqual(len(response), 1)
216 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
217 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
218 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
219 if not self.connection.strategy.sync:
220 sleep(2)
221 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
222 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
223 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
224
225 def test_modify_operation_from_byte_values(self):
226 if str is not bytes: # integer list to bytes works only in Python 3
227 single = make_bytes([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
228 multi = [make_bytes([195, 160, 195, 168, 195, 172]), make_bytes([195, 178, 195, 185])]
229 single_mod = make_bytes([195, 185, 195, 178, 195, 172, 195, 168, 195, 160])
230 multi_mod = [make_bytes([195, 172, 195, 168, 195, 160]), make_bytes([195, 185, 195, 178])]
231 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-13', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
232 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
233 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
234 self.assertEqual(len(response), 1)
235 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
236 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
237 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
238 if not self.connection.strategy.sync:
239 sleep(2)
240 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
241 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
242 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
243
244 def test_modify_operation_from_unicode_literal(self):
245 single = make_bytes(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
246 multi = [make_bytes(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytes('\u00f2\u00f9', 'utf-8')]
247 single_mod = make_bytes(u'\u00f9\u00f2\u00ec\u00e8\u00e0', 'utf-8')
248 multi_mod = [make_bytes(u'\u00ec\u00e8\u00e0', 'utf-8'), make_bytes('\u00f9\u00f2', 'utf-8')]
249 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-14', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
250 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
251 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
252 self.assertEqual(len(response), 1)
253 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
254 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
255 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
256 if not self.connection.strategy.sync:
257 sleep(2)
258 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
259 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
260 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
261
262 def test_modify_operation_from_unicode_name(self):
263 if str is not bytes: # works only in Python 3
264 single = make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
265 multi = [make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytes('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
266 single_mod = make_bytes('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8')
267 multi_mod = [make_bytes('\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8'), make_bytes('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}', 'utf-8')]
268 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-15', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
269 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
270 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
271 self.assertEqual(len(response), 1)
272 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
273 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
274 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
275 if not self.connection.strategy.sync:
276 sleep(2)
277 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
278 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
279 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
280
281 def test_modify_operation_from_bytearray(self):
282 single = make_bytearray('àèìòù', 'utf-8')
283 multi = [make_bytearray('àèì', 'utf-8'), make_bytearray('òù', 'utf-8')]
284 single_mod = make_bytearray('ùòìèà', 'utf-8')
285 multi_mod = [make_bytearray('ìèà', 'utf-8'), make_bytearray('ùò', 'utf-8')]
286 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-16', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
287 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
288 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
289 self.assertEqual(len(response), 1)
290 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
291 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
292 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
293 if not self.connection.strategy.sync:
294 sleep(2)
295 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
296 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
297 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
298
299 def test_modify_operation_from_bytearray_values(self):
300 single = make_bytearray([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
301 multi = [make_bytearray([195, 160, 195, 168, 195, 172]), make_bytearray([195, 178, 195, 185])]
302 single_mod = make_bytearray([195, 185, 195, 178, 195, 172, 195, 168, 195, 160])
303 multi_mod = [make_bytearray([195, 172, 195, 168, 195, 160]), make_bytearray([195, 185, 195, 178])]
304 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-17', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
305 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
306 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
307 self.assertEqual(len(response), 1)
308 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
309 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
310 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
311 if not self.connection.strategy.sync:
312 sleep(2)
313 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
314 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
315 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
316
317 def test_modify_operation_from_bytearray_unicode_literal(self):
318 single = make_bytearray(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
319 multi = [make_bytearray(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytearray(u'\u00f2\u00f9', 'utf-8')]
320 single_mod = make_bytearray(u'\u00f9\u00f2\u00ec\u00e8\u00e0', 'utf-8')
321 multi_mod = [make_bytearray(u'\u00ec\u00e8\u00e0', 'utf-8'), make_bytearray('\u00f9\u00f2', 'utf-8')]
322 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-18', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
323 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
324 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
325 self.assertEqual(len(response), 1)
326 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
327 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
328 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
329 if not self.connection.strategy.sync:
330 sleep(2)
331 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
332 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
333 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
334
335 def test_modify_operation_from_bytearray_unicode_name(self):
336 if str is not bytes: # works only in python 3
337 single = make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
338 multi = [make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
339 single_mod = make_bytearray('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8')
340 multi_mod = [make_bytearray('\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}', 'utf-8')]
341 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-19', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
342 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
343 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
344 self.assertEqual(len(response), 1)
345 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
346 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
347 self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
348 if not self.connection.strategy.sync:
349 sleep(2)
350 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
351 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
352 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
353
354 def test_search_operation_from_bytes_literal(self):
355 single = b'abc'
356 multi = [b'abc', b'def']
357 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-20', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
358 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
359 if str is bytes: # python 2
360 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
361 else:
362 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
363 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
364
365 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
366 self.assertEqual(len(response), 1)
367 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
368 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
369
370 def test_search_operation_from_bytes(self):
371 single = make_bytes('àèìòù', 'utf-8')
372 multi = [make_bytes('àèì', 'utf-8'), make_bytes('òù', 'utf-8')]
373 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-21', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
374 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
375 if str is bytes: # python 2
376 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
377 else:
378 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
379 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
380 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
381 self.assertEqual(len(response), 1)
382 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
383 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
384
385 def test_search_operation_from_byte_values(self):
386 if str is not bytes: # integer list to bytes works only in Python 3
387 single = make_bytes([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
388 multi = [make_bytes([195, 160, 195, 168, 195, 172]), make_bytes([195, 178, 195, 185])]
389 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-22', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
390 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
391 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
392 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
393 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
394 self.assertEqual(len(response), 1)
395 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
396 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
397
398 def test_search_operation_from_unicode_literal(self):
399 single = make_bytes(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
400 multi = [make_bytes(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytes('\u00f2\u00f9', 'utf-8')]
401 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-23', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
402 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
403 if str is bytes: # python 2
404 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
405 else:
406 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
407 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
408 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
409 self.assertEqual(len(response), 1)
410 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
411 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
412
413 def test_search_operation_from_unicode_name(self):
414 if str is not bytes: # works only in Python 3
415 single = make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
416 multi = [make_bytes('\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytes('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
417 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-24', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
418 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
419 if str is bytes: # python 2
420 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
421 else:
422 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
423 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
424 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
425 self.assertEqual(len(response), 1)
426 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
427 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
428
429 def test_search_operation_from_bytearray(self):
430 single = make_bytearray('àèìòù', 'utf-8')
431 multi = [make_bytearray('àèì', 'utf-8'), make_bytearray('òù', 'utf-8')]
432 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-25', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
433 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
434 if str is bytes: # python 2
435 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
436 else:
437 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
438 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
439 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
440 self.assertEqual(len(response), 1)
441 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
442 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
443
444 def test_search_operation_from_bytearray_values(self):
445 single = make_bytearray([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
446 multi = [make_bytearray([195, 160, 195, 168, 195, 172]), make_bytearray([195, 178, 195, 185])]
447 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-26', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
448 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
449 if str is bytes: # python 2
450 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
451 else:
452 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
453 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
454 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
455 self.assertEqual(len(response), 1)
456 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
457 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
458
459 def test_search_operation_from_bytearray_unicode_literal(self):
460 single = make_bytearray(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
461 multi = [make_bytearray(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytearray(u'\u00f2\u00f9', 'utf-8')]
462 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-27', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
463 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
464 if str is bytes: # python 2
465 byte_filter = b'(&(%s=*%s*)(%s=%s))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
466 else:
467 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
468 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
469 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
470 self.assertEqual(len(response), 1)
471 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
472 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
473
474 def test_search_operation_from_bytearray_unicode_name(self):
475 if str is not bytes: # works only in python 3
476 single = make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
477 multi = [make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
478 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-28', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
479 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
480 # byte_filter = b'(&(%b=*%b*)(%b=%b))' % (make_bytes(test_name_attr, 'utf-8'), make_bytes(testcase_id, 'utf-8'), make_bytes(test_singlevalued_attribute, 'utf-8'), single)
481 byte_filter = b'(&(' + make_bytes(test_name_attr, 'utf-8') + b'=*' + make_bytes(testcase_id, 'utf-8') + b'*)(' + make_bytes(test_singlevalued_attribute, 'utf-8') + b'=' + single + b'))'
482 status, result, response, request = get_response_values(self.connection.search(test_base, byte_filter, attributes=[test_singlevalued_attribute, test_multivalued_attribute]), self.connection)
483 self.assertEqual(len(response), 1)
484 self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
485 self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
486
487 def test_modify_operation_from_bytes_for_objectclass(self):
488 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-29', test_bytes=True))
489 self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
490 result = self.connection.modify(self.delete_at_teardown[0][0], {'objectClass': (MODIFY_REPLACE, [b'top', b'organizationalunit'])})
491 if not self.connection.strategy.sync:
492 sleep(2)
493 response, result = self.connection.get_response(result)
494 else:
495 result = self.connection.result
496
497 self.assertTrue(result['description'], ['objectClassViolation', 'objectClassModsProhibited'])
498