Skip to content

Check for LDAP schema and slapd binaries #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SlapdObject(object):
elif os.path.isdir("/etc/ldap/schema"):
SCHEMADIR = "/etc/ldap/schema"
else:
PATH_SCHEMA_CORE = None
SCHEMADIR = None
PATH_LDAPADD = os.path.join(BINDIR, 'ldapadd')
PATH_LDAPMODIFY = os.path.join(BINDIR, 'ldapmodify')
PATH_LDAPWHOAMI = os.path.join(BINDIR, 'ldapwhoami')
Expand All @@ -138,6 +138,17 @@ def __init__(self):
ldapi_path = os.path.join(self.testrundir, 'ldapi')
self.ldapi_uri = "ldapi://%s" % quote_plus(ldapi_path)

def _check_requirements(self):
binaries = [
self.PATH_LDAPADD, self.PATH_LDAPMODIFY, self.PATH_LDAPWHOAMI,
self.PATH_SLAPD, self.PATH_SLAPTEST
]
for binary in binaries:
if not os.path.isfile(binary):
raise ValueError('Binary {} is missing.'.format(binary))
if self.SCHEMADIR is None:
raise ValueError('SCHEMADIR is None, ldap schemas are missing.')

def setup_rundir(self):
"""
creates rundir structure
Expand Down Expand Up @@ -283,6 +294,7 @@ def start(self):
"""

if self._proc is None:
self._check_requirements()
# prepare directory structure
atexit.register(self.stop)
self._cleanup_rundir()
Expand Down
25 changes: 12 additions & 13 deletions Tests/t_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@
from slapdtest import SlapdObject
from ldap.ldapobject import LDAPObject

server = None


class TestBinds(unittest.TestCase):

def setUp(self):
global server
if server is None:
server = SlapdObject()
server.start()
@classmethod
def setUpClass(cls):
cls.server = SlapdObject()
cls.server.start()

cls.unicode_val = "abc\U0001f498def"
cls.unicode_val_bytes = cls.unicode_val.encode('utf-8')

self.server = server
self.unicode_val = "abc\U0001f498def"
self.unicode_val_bytes = self.unicode_val.encode('utf-8')
cls.dn_unicode = "CN=" + cls.unicode_val
cls.dn_bytes = cls.dn_unicode.encode('utf-8')

self.dn_unicode = "CN=" + self.unicode_val
self.dn_bytes = self.dn_unicode.encode('utf-8')
@classmethod
def tearDownClass(cls):
cls.server.stop()

def _get_ldapobject(self, bytes_mode=None):
l = LDAPObject(self.server.ldap_uri, bytes_mode=bytes_mode)
Expand Down
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