server/test/unittest_ldapsource.py
changeset 10612 84468b90e9c1
parent 10609 e2d8e81bfe68
child 10614 57dfde80df11
equal deleted inserted replaced
10611:f4dec0cca9a1 10612:84468b90e9c1
    24 import time
    24 import time
    25 from os.path import join, exists
    25 from os.path import join, exists
    26 import subprocess
    26 import subprocess
    27 import tempfile
    27 import tempfile
    28 
    28 
       
    29 from six import string_types
    29 from six.moves import range
    30 from six.moves import range
    30 
    31 
    31 from logilab.common.testlib import TestCase, unittest_main, mock_object, Tags
    32 from logilab.common.testlib import TestCase, unittest_main, mock_object, Tags
    32 
    33 
    33 from cubicweb import AuthenticationError
    34 from cubicweb import AuthenticationError
   153         """
   154         """
   154         add an LDAP entity
   155         add an LDAP entity
   155         """
   156         """
   156         modcmd = ['dn: %s'%dn, 'changetype: add']
   157         modcmd = ['dn: %s'%dn, 'changetype: add']
   157         for key, values in mods.iteritems():
   158         for key, values in mods.iteritems():
   158             if isinstance(values, basestring):
   159             if isinstance(values, string_types):
   159                 values = [values]
   160                 values = [values]
   160             for value in values:
   161             for value in values:
   161                 modcmd.append('%s: %s'%(key, value))
   162                 modcmd.append('%s: %s'%(key, value))
   162         self._ldapmodify(modcmd)
   163         self._ldapmodify(modcmd)
   163 
   164 
   173         modify one or more attributes of an LDAP entity
   174         modify one or more attributes of an LDAP entity
   174         """
   175         """
   175         modcmd = ['dn: %s'%dn, 'changetype: modify']
   176         modcmd = ['dn: %s'%dn, 'changetype: modify']
   176         for (kind, key), values in mods.iteritems():
   177         for (kind, key), values in mods.iteritems():
   177             modcmd.append('%s: %s' % (kind, key))
   178             modcmd.append('%s: %s' % (kind, key))
   178             if isinstance(values, basestring):
   179             if isinstance(values, string_types):
   179                 values = [values]
   180                 values = [values]
   180             for value in values:
   181             for value in values:
   181                 modcmd.append('%s: %s'%(key, value))
   182                 modcmd.append('%s: %s'%(key, value))
   182             modcmd.append('-')
   183             modcmd.append('-')
   183         self._ldapmodify(modcmd)
   184         self._ldapmodify(modcmd)