From 06be5eb9acd0f27554011819be7a938d250ef125 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 27 Mar 2018 02:28:09 -0700 Subject: [PATCH] Make SlapdObject.root_dn a property Allows overriding SlapdObject.suffix or SlapdObject.root_cn without also requiring root_dn be defined. It is now computed from the existing values at runtime. The result is an easier to use SlapdObject class. https://github.com/python-ldap/python-ldap/pull/195 --- Lib/slapdtest/_slapdtest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/slapdtest/_slapdtest.py b/Lib/slapdtest/_slapdtest.py index 7e230c8..2bbd141 100644 --- a/Lib/slapdtest/_slapdtest.py +++ b/Lib/slapdtest/_slapdtest.py @@ -169,7 +169,6 @@ class SlapdObject(object): database = 'mdb' suffix = 'dc=slapd-test,dc=python-ldap,dc=org' root_cn = 'Manager' - root_dn = 'cn=%s,%s' % (root_cn, suffix) root_pw = 'password' slapd_loglevel = 'stats stats2' local_host = '127.0.0.1' @@ -232,6 +231,10 @@ def __init__(self): self.clientcert = os.path.join(HERE, 'certs/client.pem') self.clientkey = os.path.join(HERE, 'certs/client.key') + @property + def root_dn(self): + return 'cn={self.root_cn},{self.suffix}'.format(self=self) + def _find_commands(self): self.PATH_LDAPADD = self._find_command('ldapadd') self.PATH_LDAPDELETE = self._find_command('ldapdelete')