Skip to content

Commit 22c3ccf

Browse files
committed
Set LDAPNOINIT env in all tests
All test suites are now setting LDAPNOINIT to prevent processing of /etc/openldap/ldap.conf. This fixes TLS tests when ldap.conf contains a relaxed TLS_REQCERT option. See: #169 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent 7d69bbd commit 22c3ccf

17 files changed

+65
-25
lines changed

Tests/t_bind.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
PY2 = False
1010
text_type = str
1111

12-
import ldap, unittest
13-
from slapdtest import SlapdTestCase
12+
import os
13+
import unittest
14+
15+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
16+
os.environ['LDAPNOINIT'] = '1'
17+
18+
import ldap
1419
from ldap.ldapobject import LDAPObject
20+
from slapdtest import SlapdTestCase
1521

1622

1723
class TestBinds(SlapdTestCase):

Tests/t_cext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
import os
1111
import unittest
1212

13-
from slapdtest import SlapdTestCase, requires_tls
14-
1513
# Switch off processing .ldaprc or ldap.conf before importing _ldap
1614
os.environ['LDAPNOINIT'] = '1'
1715

1816
# import the plain C wrapper module
1917
import _ldap
18+
from slapdtest import SlapdTestCase, requires_tls
2019

2120

2221
class TestLdapCExtension(SlapdTestCase):

Tests/t_cidict.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
See https://www.python-ldap.org/ for details.
66
"""
77

8-
# from Python's standard lib
8+
import os
99
import unittest
1010

11-
# from python-ldap
12-
import ldap, ldap.cidict
11+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
12+
os.environ['LDAPNOINIT'] = '1'
13+
import ldap
14+
import ldap.cidict
1315

1416

1517
class TestCidict(unittest.TestCase):

Tests/t_edit.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
PY2 = False
1010
text_type = str
1111

12-
import ldap, unittest
13-
from slapdtest import SlapdTestCase
12+
import os
13+
import unittest
14+
15+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
16+
os.environ['LDAPNOINIT'] = '1'
1417

18+
import ldap
1519
from ldap.ldapobject import LDAPObject
20+
from slapdtest import SlapdTestCase
1621

1722

1823
class EditionTests(SlapdTestCase):

Tests/t_ldap_controls_libldap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Switch off processing .ldaprc or ldap.conf before importing _ldap
55
os.environ['LDAPNOINIT'] = '1'
66

7-
import ldap
87
from ldap.controls import pagedresults
98
from ldap.controls import libldap
109

Tests/t_ldap_dn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
from __future__ import unicode_literals
99

1010
# from Python's standard lib
11+
import os
1112
import unittest
1213

13-
# from python-ldap
14+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
15+
os.environ['LDAPNOINIT'] = '1'
1416
import ldap.dn
1517

1618

Tests/t_ldap_filter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
See https://www.python-ldap.org/ for details.
66
"""
77

8-
# from Python's standard lib
8+
import os
99
import unittest
1010

11-
# from python-ldap
11+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
12+
os.environ['LDAPNOINIT'] = '1'
13+
1214
from ldap.filter import escape_filter_chars
1315

1416

Tests/t_ldap_functions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
See https://www.python-ldap.org/ for details.
66
"""
77

8-
# from Python's standard lib
8+
import os
99
import unittest
1010

11-
# from python-ldap
11+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
12+
os.environ['LDAPNOINIT'] = '1'
13+
1214
import ldap
1315
from ldap.dn import escape_dn_chars
1416
from ldap.filter import escape_filter_chars

Tests/t_ldap_modlist.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
See https://www.python-ldap.org/ for details.
66
"""
77

8+
import os
89
import unittest
910

10-
import ldap
11+
# Switch off processing .ldaprc or ldap.conf before importing _ldap
12+
os.environ['LDAPNOINIT'] = '1'
1113

14+
import ldap
1215
from ldap.modlist import addModlist,modifyModlist
1316

17+
1418
class TestModlist(unittest.TestCase):
1519

1620
addModlist_tests = [

Tests/t_ldap_options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
# Switch off processing .ldaprc or ldap.conf before importing _ldap
55
os.environ['LDAPNOINIT'] = '1'
66

7+
from slapdtest import SlapdTestCase, requires_tls
8+
79
import ldap
810
from ldap.controls import RequestControlTuples
911
from ldap.controls.pagedresults import SimplePagedResultsControl
1012
from ldap.controls.openldap import SearchNoOpControl
1113
from ldap.ldapobject import SimpleLDAPObject
12-
from slapdtest import SlapdTestCase, requires_tls
14+
1315

1416
SENTINEL = object()
1517

0 commit comments

Comments
 (0)