|
4 | 4 |
|
5 | 5 | See https://www.python-ldap.org/ for details.
|
6 | 6 |
|
7 |
| -$Id: slapdtest.py,v 1.18 2017/08/15 17:18:54 stroeder Exp $ |
| 7 | +$Id: slapdtest.py,v 1.19 2017/08/16 13:29:06 stroeder Exp $ |
8 | 8 |
|
9 | 9 | Python compability note:
|
10 | 10 | This module only works with Python 2.7.x since
|
@@ -83,7 +83,7 @@ class SlapdObject(object):
|
83 | 83 | Controller class for a slapd instance, OpenLDAP's server.
|
84 | 84 |
|
85 | 85 | This class creates a temporary data store for slapd, runs it
|
86 |
| - on a private port, and initialises it with a top-level dc and |
| 86 | + listening on a private Unix domain socket and TCP port, and initialises it with a top-level entry and |
87 | 87 | the root user.
|
88 | 88 |
|
89 | 89 | When a reference to an instance of this class is lost, the slapd
|
@@ -132,9 +132,12 @@ def __init__(self):
|
132 | 132 | ldapi_path = os.path.join(self.testrundir, 'ldapi')
|
133 | 133 | self.ldapi_uri = "ldapi://%s" % urllib.quote_plus(ldapi_path)
|
134 | 134 |
|
135 |
| - def _setup_rundir(self): |
| 135 | + def setup_rundir(self): |
136 | 136 | """
|
137 | 137 | creates rundir structure
|
| 138 | +
|
| 139 | + for setting up a custom directory structure you have to override |
| 140 | + this method |
138 | 141 | """
|
139 | 142 | os.mkdir(self.testrundir)
|
140 | 143 | os.mkdir(self._db_directory)
|
@@ -172,9 +175,12 @@ def _avail_tcp_port(self):
|
172 | 175 | self._log.info('Found available port %d', port)
|
173 | 176 | return port
|
174 | 177 |
|
175 |
| - def _gen_config(self): |
| 178 | + def gen_config(self): |
176 | 179 | """
|
177 | 180 | generates a slapd.conf and returns it as one string
|
| 181 | +
|
| 182 | + for generating specific static configuration files you have to |
| 183 | + override this method |
178 | 184 | """
|
179 | 185 | config_dict = {
|
180 | 186 | 'serverid': hex(self.server_id),
|
@@ -213,7 +219,7 @@ def _write_config(self):
|
213 | 219 | """Writes the slapd.conf file out, and returns the path to it."""
|
214 | 220 | self._log.debug('Writing config to %s', self._slapd_conf)
|
215 | 221 | config_file = file(self._slapd_conf, 'wb')
|
216 |
| - config_file.write(self._gen_config()) |
| 222 | + config_file.write(self.gen_config()) |
217 | 223 | config_file.close()
|
218 | 224 | self._log.info('Wrote config to %s', self._slapd_conf)
|
219 | 225 |
|
@@ -271,7 +277,7 @@ def start(self):
|
271 | 277 | if self._proc is None:
|
272 | 278 | # prepare directory structure
|
273 | 279 | self._cleanup_rundir()
|
274 |
| - self._setup_rundir() |
| 280 | + self.setup_rundir() |
275 | 281 | self._write_config()
|
276 | 282 | self._test_config()
|
277 | 283 | self._start_slapd()
|
|
0 commit comments