Skip to content

Commit

Permalink
Make SlapdObject.root_dn a property
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jon Dufresne authored and Petr Viktorin committed Mar 27, 2018
1 parent 4a6a719 commit 06be5eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/slapdtest/_slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 06be5eb

Please sign in to comment.