Skip to content

Commit

Permalink
Set LDAPNOINIT env in all tests
Browse files Browse the repository at this point in the history
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: https://github.com/python-ldap/python-ldap/issues/169
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
Christian Heimes committed Jan 18, 2018
1 parent 7d69bbd commit 22c3ccf
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 25 deletions.
10 changes: 8 additions & 2 deletions Tests/t_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
PY2 = False
text_type = str

import ldap, unittest
from slapdtest import SlapdTestCase
import os
import unittest

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

import ldap
from ldap.ldapobject import LDAPObject
from slapdtest import SlapdTestCase


class TestBinds(SlapdTestCase):
Expand Down
3 changes: 1 addition & 2 deletions Tests/t_cext.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
import os
import unittest

from slapdtest import SlapdTestCase, requires_tls

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

# import the plain C wrapper module
import _ldap
from slapdtest import SlapdTestCase, requires_tls


class TestLdapCExtension(SlapdTestCase):
Expand Down
8 changes: 5 additions & 3 deletions Tests/t_cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
See https://www.python-ldap.org/ for details.
"""

# from Python's standard lib
import os
import unittest

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


class TestCidict(unittest.TestCase):
Expand Down
9 changes: 7 additions & 2 deletions Tests/t_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
PY2 = False
text_type = str

import ldap, unittest
from slapdtest import SlapdTestCase
import os
import unittest

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

import ldap
from ldap.ldapobject import LDAPObject
from slapdtest import SlapdTestCase


class EditionTests(SlapdTestCase):
Expand Down
1 change: 0 additions & 1 deletion Tests/t_ldap_controls_libldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Switch off processing .ldaprc or ldap.conf before importing _ldap
os.environ['LDAPNOINIT'] = '1'

import ldap
from ldap.controls import pagedresults
from ldap.controls import libldap

Expand Down
4 changes: 3 additions & 1 deletion Tests/t_ldap_dn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from __future__ import unicode_literals

# from Python's standard lib
import os
import unittest

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


Expand Down
6 changes: 4 additions & 2 deletions Tests/t_ldap_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
See https://www.python-ldap.org/ for details.
"""

# from Python's standard lib
import os
import unittest

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

from ldap.filter import escape_filter_chars


Expand Down
6 changes: 4 additions & 2 deletions Tests/t_ldap_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
See https://www.python-ldap.org/ for details.
"""

# from Python's standard lib
import os
import unittest

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

import ldap
from ldap.dn import escape_dn_chars
from ldap.filter import escape_filter_chars
Expand Down
6 changes: 5 additions & 1 deletion Tests/t_ldap_modlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
See https://www.python-ldap.org/ for details.
"""

import os
import unittest

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

import ldap
from ldap.modlist import addModlist,modifyModlist


class TestModlist(unittest.TestCase):

addModlist_tests = [
Expand Down
4 changes: 3 additions & 1 deletion Tests/t_ldap_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Switch off processing .ldaprc or ldap.conf before importing _ldap
os.environ['LDAPNOINIT'] = '1'

from slapdtest import SlapdTestCase, requires_tls

import ldap
from ldap.controls import RequestControlTuples
from ldap.controls.pagedresults import SimplePagedResultsControl
from ldap.controls.openldap import SearchNoOpControl
from ldap.ldapobject import SimpleLDAPObject
from slapdtest import SlapdTestCase, requires_tls


SENTINEL = object()

Expand Down
1 change: 0 additions & 1 deletion Tests/t_ldap_sasl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
See https://www.python-ldap.org/ for details.
"""
import os
import socket
import unittest

# Switch off processing .ldaprc or ldap.conf before importing _ldap
Expand Down
4 changes: 4 additions & 0 deletions Tests/t_ldap_schema_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
See https://www.python-ldap.org/ for details.
"""

import os
import unittest

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

import ldap.schema

# basic test cases
Expand Down
4 changes: 2 additions & 2 deletions Tests/t_ldap_syncrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
else:
PY2 = False

from slapdtest import SlapdObject, SlapdTestCase

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

import ldap
from ldap.ldapobject import SimpleLDAPObject
from ldap.syncrepl import SyncreplConsumer

from slapdtest import SlapdObject, SlapdTestCase

# a template string for generating simple slapd.conf file
SLAPD_CONF_PROVIDER_TEMPLATE = r"""
serverID %(serverid)s
Expand Down
6 changes: 4 additions & 2 deletions Tests/t_ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
import unittest
import warnings
import pickle
from slapdtest import SlapdTestCase
from slapdtest import requires_ldapi, requires_sasl, requires_tls

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

import ldap
from ldap.ldapobject import SimpleLDAPObject, ReconnectLDAPObject

from slapdtest import SlapdTestCase
from slapdtest import requires_ldapi, requires_sasl, requires_tls


LDIF_TEMPLATE = """dn: %(suffix)s
objectClass: dcObject
objectClass: organization
Expand Down
5 changes: 5 additions & 0 deletions Tests/t_ldapurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

from __future__ import unicode_literals

import os
import unittest

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

from ldap.compat import quote

import ldapurl
Expand Down
8 changes: 5 additions & 3 deletions Tests/t_ldif.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

from __future__ import unicode_literals

# from Python's standard lib
import unittest
import os
import textwrap
import unittest

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

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

import ldif


Expand Down
5 changes: 5 additions & 0 deletions Tests/t_untested_mods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# modules without any tests

import os

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

import ldap.controls.deref
import ldap.controls.openldap
import ldap.controls.ppolicy
Expand Down

0 comments on commit 22c3ccf

Please sign in to comment.