Skip to content

Commit

Permalink
SlapdObject methods setup_rundir() and gen_config() are now "public" …
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
stroeder committed Aug 16, 2017
1 parent 351452e commit cdc169a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changes since 2.4.41:
Lib/
* added new SlapdObject methods _ln_schema_files() and
_create_sub_dirs()
* SlapdObject methods setup_rundir() and gen_config()
are now "public" methods
* removed pseudo test script from module ldap.cidict

Tests/
Expand Down Expand Up @@ -1473,4 +1475,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.455 2017/08/15 16:14:04 stroeder Exp $
$Id: CHANGES,v 1.456 2017/08/16 13:29:05 stroeder Exp $
18 changes: 12 additions & 6 deletions Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See https://www.python-ldap.org/ for details.
$Id: slapdtest.py,v 1.18 2017/08/15 17:18:54 stroeder Exp $
$Id: slapdtest.py,v 1.19 2017/08/16 13:29:06 stroeder Exp $
Python compability note:
This module only works with Python 2.7.x since
Expand Down Expand Up @@ -83,7 +83,7 @@ class SlapdObject(object):
Controller class for a slapd instance, OpenLDAP's server.
This class creates a temporary data store for slapd, runs it
on a private port, and initialises it with a top-level dc and
listening on a private Unix domain socket and TCP port, and initialises it with a top-level entry and
the root user.
When a reference to an instance of this class is lost, the slapd
Expand Down Expand Up @@ -132,9 +132,12 @@ def __init__(self):
ldapi_path = os.path.join(self.testrundir, 'ldapi')
self.ldapi_uri = "ldapi://%s" % urllib.quote_plus(ldapi_path)

def _setup_rundir(self):
def setup_rundir(self):
"""
creates rundir structure
for setting up a custom directory structure you have to override
this method
"""
os.mkdir(self.testrundir)
os.mkdir(self._db_directory)
Expand Down Expand Up @@ -172,9 +175,12 @@ def _avail_tcp_port(self):
self._log.info('Found available port %d', port)
return port

def _gen_config(self):
def gen_config(self):
"""
generates a slapd.conf and returns it as one string
for generating specific static configuration files you have to
override this method
"""
config_dict = {
'serverid': hex(self.server_id),
Expand Down Expand Up @@ -213,7 +219,7 @@ def _write_config(self):
"""Writes the slapd.conf file out, and returns the path to it."""
self._log.debug('Writing config to %s', self._slapd_conf)
config_file = file(self._slapd_conf, 'wb')
config_file.write(self._gen_config())
config_file.write(self.gen_config())
config_file.close()
self._log.info('Wrote config to %s', self._slapd_conf)

Expand Down Expand Up @@ -271,7 +277,7 @@ def start(self):
if self._proc is None:
# prepare directory structure
self._cleanup_rundir()
self._setup_rundir()
self.setup_rundir()
self._write_config()
self._test_config()
self._start_slapd()
Expand Down

0 comments on commit cdc169a

Please sign in to comment.