From 31784791b62225898600da1fd80c28fe665326c1 Mon Sep 17 00:00:00 2001 From: stroeder Date: Fri, 28 Apr 2017 06:21:04 +0000 Subject: [PATCH] Removed method SlapdObject.started() --- CHANGES | 6 ++++-- Tests/t_cext.py | 25 +++++++++++++++++++++++++ Tests/t_ldapobject.py | 24 ++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 530e245..1b84aa2 100644 --- a/CHANGES +++ b/CHANGES @@ -10,11 +10,13 @@ Lib/slapdtest.py in methods ldapadd() and ldapwhoami() * added method slaptest.SlapdObject.ldapmodify() * fixed enabling logger in slaptest -* directory name now contains port to be able to run several SlapdObject +* directory name now contains port to be able to run several SlapdObject instances side-by-side (e.g. with replication) * added authz-regexp mapping to rootdn for user running the test * internally use SASL/EXTERNAL via LDAPI to bind * SlapdObject.server_id used as serverID in slapd.conf for MMR +* Removed method SlapdObject.started() because SlapdTestCase.setUpClass() + will be used to add initial entries Tests/ * ReconnectLDAPObject is also tested by sub-classing test class @@ -1430,4 +1432,4 @@ Released 2.0.0pre02 2002-02-01 ---------------------------------------------------------------- Released 1.10alpha3 2000-09-19 -$Id: CHANGES,v 1.441 2017/04/27 16:45:19 stroeder Exp $ +$Id: CHANGES,v 1.442 2017/04/28 06:21:04 stroeder Exp $ diff --git a/Tests/t_cext.py b/Tests/t_cext.py index 1da4116..173c28d 100644 --- a/Tests/t_cext.py +++ b/Tests/t_cext.py @@ -21,6 +21,31 @@ class TestLdapCExtension(SlapdTestCase): timeout = 5 + @classmethod + def setUpClass(cls): + SlapdTestCase.setUpClass() + # add two initial objects after server was started and is still empty + suffix_dc = cls.server.suffix.split(',')[0][3:] + cls.server._log.debug( + "adding %s and %s", + cls.server.suffix, + cls.server.root_dn, + ) + cls.server.ldapadd( + "\n".join([ + 'dn: '+cls.server.suffix, + 'objectClass: dcObject', + 'objectClass: organization', + 'dc: '+suffix_dc, + 'o: '+suffix_dc, + '', + 'dn: '+cls.server.root_dn, + 'objectClass: applicationProcess', + 'cn: '+cls.server.root_cn, + '' + ]) + ) + def _open_conn(self, bind=True): """ Starts a server, and returns a LDAPObject bound to it diff --git a/Tests/t_ldapobject.py b/Tests/t_ldapobject.py index 6c650e8..4795ac4 100644 --- a/Tests/t_ldapobject.py +++ b/Tests/t_ldapobject.py @@ -12,7 +12,19 @@ import ldap from ldap.ldapobject import SimpleLDAPObject, ReconnectLDAPObject -LDIF_TEMPLATE = """dn: cn=Foo1,%(suffix)s +LDIF_TEMPLATE = """dn: %(suffix)s +objectClass: dcObject +objectClass: organization +dc: %(dc)s +o: %(dc)s + +dn: %(rootdn)s +objectClass: applicationProcess +objectClass: simpleSecurityObject +cn: %(rootcn)s +userPassword: %(rootpw)s + +dn: cn=Foo1,%(suffix)s objectClass: organizationalRole cn: Foo1 @@ -46,7 +58,15 @@ class Test01_SimpleLDAPObject(SlapdTestCase): def setUpClass(cls): SlapdTestCase.setUpClass() # insert some Foo* objects via ldapadd - cls.server.ldapadd(LDIF_TEMPLATE % {'suffix':cls.server.suffix}) + cls.server.ldapadd( + LDIF_TEMPLATE % { + 'suffix':cls.server.suffix, + 'rootdn':cls.server.root_dn, + 'rootcn':cls.server.root_cn, + 'rootpw':cls.server.root_pw, + 'dc': cls.server.suffix.split(',')[0][3:], + } + ) def setUp(self): try: