Skip to content

Commit

Permalink
Add reproducer for NSS callback issue
Browse files Browse the repository at this point in the history
The new test case simply creates 10 connections and calls start_tls_s()
after OPT_X_TLS_NEWCTX.

https://github.com/python-ldap/python-ldap/pull/134
See: https://github.com/python-ldap/python-ldap/issues/60
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and Petr Viktorin committed Dec 15, 2017
1 parent 4bc1f58 commit 5197e58
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Tests/t_ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import warnings
import pickle
import warnings
from slapdtest import SlapdTestCase, requires_sasl
from slapdtest import SlapdTestCase, requires_sasl, requires_tls

# Switch off processing .ldaprc or ldap.conf before importing _ldap
os.environ['LDAPNOINIT'] = '1'
Expand Down Expand Up @@ -418,6 +418,20 @@ def test_byteswarning_initialize(self):
self._check_byteswarning(
w[0], u"Under Python 2, python-ldap uses bytes by default.")

@requires_tls()
def test_multiple_starttls(self):
# Test for openldap does not re-register nss shutdown callbacks
# after nss_Shutdown is called
# https://github.com/python-ldap/python-ldap/issues/60
# https://bugzilla.redhat.com/show_bug.cgi?id=1520990
for _ in range(10):
l = self.ldap_object_class(self.server.ldap_uri)
l.set_option(ldap.OPT_X_TLS_CACERTFILE, self.server.cafile)
l.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
l.start_tls_s()
l.simple_bind_s(self.server.root_dn, self.server.root_pw)
self.assertEqual(l.whoami_s(), 'dn:' + self.server.root_dn)


class Test01_ReconnectLDAPObject(Test00_SimpleLDAPObject):
"""
Expand Down

0 comments on commit 5197e58

Please sign in to comment.