equal
deleted
inserted
replaced
18 """cubicweb.server.sources.ldapfeed unit and functional tests |
18 """cubicweb.server.sources.ldapfeed unit and functional tests |
19 |
19 |
20 Those tests expect to have slapd, python-ldap3 and ldapscripts packages installed. |
20 Those tests expect to have slapd, python-ldap3 and ldapscripts packages installed. |
21 """ |
21 """ |
22 |
22 |
23 from __future__ import print_function |
|
24 |
|
25 import os |
23 import os |
26 import sys |
24 import sys |
27 import shutil |
25 import shutil |
28 import time |
26 import time |
29 import subprocess |
27 import subprocess |
30 import tempfile |
28 import tempfile |
31 import unittest |
29 import unittest |
32 from os.path import join |
30 from os.path import join |
33 |
|
34 from six import string_types |
|
35 from six.moves import range |
|
36 |
31 |
37 from cubicweb import AuthenticationError, ValidationError |
32 from cubicweb import AuthenticationError, ValidationError |
38 from cubicweb.devtools.testlib import CubicWebTC |
33 from cubicweb.devtools.testlib import CubicWebTC |
39 from cubicweb.devtools.httptest import get_available_port |
34 from cubicweb.devtools.httptest import get_available_port |
40 |
35 |
178 """ |
173 """ |
179 add an LDAP entity |
174 add an LDAP entity |
180 """ |
175 """ |
181 modcmd = ['dn: %s' % dn, 'changetype: add'] |
176 modcmd = ['dn: %s' % dn, 'changetype: add'] |
182 for key, values in mods.items(): |
177 for key, values in mods.items(): |
183 if isinstance(values, string_types): |
178 if isinstance(values, str): |
184 values = [values] |
179 values = [values] |
185 for value in values: |
180 for value in values: |
186 modcmd.append('%s: %s' % (key, value)) |
181 modcmd.append('%s: %s' % (key, value)) |
187 self._ldapmodify(modcmd) |
182 self._ldapmodify(modcmd) |
188 |
183 |
198 modify one or more attributes of an LDAP entity |
193 modify one or more attributes of an LDAP entity |
199 """ |
194 """ |
200 modcmd = ['dn: %s' % dn, 'changetype: modify'] |
195 modcmd = ['dn: %s' % dn, 'changetype: modify'] |
201 for (kind, key), values in mods.items(): |
196 for (kind, key), values in mods.items(): |
202 modcmd.append('%s: %s' % (kind, key)) |
197 modcmd.append('%s: %s' % (kind, key)) |
203 if isinstance(values, string_types): |
198 if isinstance(values, str): |
204 values = [values] |
199 values = [values] |
205 for value in values: |
200 for value in values: |
206 modcmd.append('%s: %s' % (key, value)) |
201 modcmd.append('%s: %s' % (key, value)) |
207 modcmd.append('-') |
202 modcmd.append('-') |
208 self._ldapmodify(modcmd) |
203 self._ldapmodify(modcmd) |