Skip to content

Commit 3e6a2ea

Browse files
author
stroeder
committed
added LDAPI support in slaptest.SlapdObject which is internally used in methods ldapadd() and ldapwhoami()
1 parent d787d3f commit 3e6a2ea

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGES

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Changes since 2.4.37:
66
Lib/
77
* slapdtest now evaluates env var SLAPD for optionally pointing
88
to OpenLDAP's slapd executable
9+
* added LDAPI support in slaptest.SlapdObject which is internally used
10+
in methods ldapadd() and ldapwhoami()
911

1012
Tests/
1113

@@ -1420,4 +1422,4 @@ Released 2.0.0pre02 2002-02-01
14201422
----------------------------------------------------------------
14211423
Released 1.10alpha3 2000-09-19
14221424

1423-
$Id: CHANGES,v 1.437 2017/04/27 11:13:39 stroeder Exp $
1425+
$Id: CHANGES,v 1.438 2017/04/27 12:24:50 stroeder Exp $

Lib/slapdtest.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
See http://www.python-ldap.org/ for details.
55
6-
\$Id: slapdtest.py,v 1.4 2017/04/27 11:13:39 stroeder Exp $
6+
\$Id: slapdtest.py,v 1.5 2017/04/27 12:24:50 stroeder Exp $
77
88
Python compability note:
99
This module only works with Python 2.7.x since
@@ -17,6 +17,7 @@
1717
import subprocess
1818
import logging
1919
import unittest
20+
import urllib
2021

2122
# determine log level
2223
try:
@@ -114,11 +115,13 @@ class SlapdObject(object):
114115
def __init__(self):
115116
self._proc = None
116117
self._port = find_available_tcp_port(LOCALHOST)
117-
self.ldap_uri = "ldap://%s:%d/" % (LOCALHOST, self._port)
118118
self._log = _LOGGER
119119
self.testrundir = os.path.join(self.TMPDIR, 'python-ldap-test')
120120
self._slapd_conf = os.path.join(self.testrundir, "slapd.conf")
121121
self._db_directory = os.path.join(self.testrundir, "openldap-data")
122+
self.ldap_uri = "ldap://%s:%d/" % (LOCALHOST, self._port)
123+
ldapi_path = os.path.join(self.testrundir, 'ldapi-%d' % self._port)
124+
self.ldapi_uri = "ldapi://%s" % urllib.quote_plus(ldapi_path)
122125

123126
def _gen_config(self):
124127
"""
@@ -177,9 +180,9 @@ def _start_slapd(self):
177180
self._log.info("starting slapd")
178181
self._proc = subprocess.Popen([
179182
self.PATH_SLAPD,
180-
"-f", self._slapd_conf,
181-
"-h", self.ldap_uri,
182-
"-d", "0",
183+
'-f', self._slapd_conf,
184+
'-h', '%s' % ' '.join((self.ldap_uri, self.ldapi_uri)),
185+
'-d', '0',
183186
])
184187

185188
def _wait_for_slapd(self):
@@ -263,7 +266,7 @@ def ldapwhoami(self, extra_args=None):
263266
"-x",
264267
"-D", self.root_dn,
265268
"-w", self.root_pw,
266-
"-H", self.ldap_uri
269+
"-H", self.ldapi_uri
267270
] + extra_args,
268271
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
269272
)
@@ -280,7 +283,7 @@ def ldapadd(self, ldif, extra_args=None):
280283
"-x",
281284
"-D", self.root_dn,
282285
"-w", self.root_pw,
283-
"-H", self.ldap_uri
286+
"-H", self.ldapi_uri
284287
] + extra_args,
285288
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
286289
)

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