Skip to content

Commit

Permalink
Lib/ldap/controls/sss: use str instead of basestring on Python 3
Browse files Browse the repository at this point in the history
* Python 3 has no basestring, use str instead
* Add a very minimal test to create a SSSRequestControl


Fixes: https://github.com/python-ldap/python-ldap/issues/255
  • Loading branch information
Ondřej Kuzník authored and Petr Viktorin committed Jan 30, 2019
1 parent 576d5bf commit 2059c13
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/ldap/controls/sss.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
]


import sys

import ldap
from ldap.ldapobject import LDAPObject
from ldap.controls import (RequestControl, ResponseControl,
Expand All @@ -20,6 +22,10 @@
from pyasn1.type import univ, namedtype, tag, namedval, constraint
from pyasn1.codec.ber import encoder, decoder

PY2 = sys.version_info[0] <= 2
if not PY2:
basestring = str


# SortKeyList ::= SEQUENCE OF SEQUENCE {
# attributeType AttributeDescription,
Expand Down
17 changes: 17 additions & 0 deletions Tests/t_ldap_controls_sss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import unittest

# Switch off processing .ldaprc or ldap.conf before importing _ldap
os.environ['LDAPNOINIT'] = '1'

from ldap.controls import sss


class TestControlsPPolicy(unittest.TestCase):
def test_create_sss_request_control(self):
control = sss.SSSRequestControl(ordering_rules=['-uidNumber'])
self.assertEqual(control.ordering_rules, ['-uidNumber'])


if __name__ == '__main__':
unittest.main()

0 comments on commit 2059c13

Please sign in to comment.