Skip to content

Commit 2059c13

Browse files
mistotebeencukou
authored andcommitted
Lib/ldap/controls/sss: use str instead of basestring on Python 3
* Python 3 has no basestring, use str instead * Add a very minimal test to create a SSSRequestControl Fixes: #255
1 parent 576d5bf commit 2059c13

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Lib/ldap/controls/sss.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
]
1313

1414

15+
import sys
16+
1517
import ldap
1618
from ldap.ldapobject import LDAPObject
1719
from ldap.controls import (RequestControl, ResponseControl,
@@ -20,6 +22,10 @@
2022
from pyasn1.type import univ, namedtype, tag, namedval, constraint
2123
from pyasn1.codec.ber import encoder, decoder
2224

25+
PY2 = sys.version_info[0] <= 2
26+
if not PY2:
27+
basestring = str
28+
2329

2430
# SortKeyList ::= SEQUENCE OF SEQUENCE {
2531
# attributeType AttributeDescription,

Tests/t_ldap_controls_sss.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import unittest
3+
4+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
5+
os.environ['LDAPNOINIT'] = '1'
6+
7+
from ldap.controls import sss
8+
9+
10+
class TestControlsPPolicy(unittest.TestCase):
11+
def test_create_sss_request_control(self):
12+
control = sss.SSSRequestControl(ordering_rules=['-uidNumber'])
13+
self.assertEqual(control.ordering_rules, ['-uidNumber'])
14+
15+
16+
if __name__ == '__main__':
17+
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy