Skip to content

Commit 8782654

Browse files
committed
feat: implement Slapd.init_tree
1 parent 5cc325d commit 8782654

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
44
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
55

6+
Added
7+
*****
8+
9+
- Implement `init_tree` method :pr:`8`
10+
611
[0.1.3] - 2023-03-12
712
====================
813

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pip install slapd
99
>>> import slapd
1010
>>> process = slapd.Slapd()
1111
>>> process.start()
12+
>>> process.init_tree()
1213
>>> process.ldapwhoami().stdout.decode("utf-8")
1314
'dn:cn=manager,dc=slapd-test,dc=python-ldap,dc=org\n'
1415
>>> process.stop()

slapd/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,3 +621,25 @@ def slapcat(self, extra_args=None, expected=0):
621621
extra_args=extra_args,
622622
expected=expected,
623623
)
624+
625+
def init_tree(self):
626+
"""
627+
Creates the organization and applicationProcess object.
628+
"""
629+
suffix_dc = self.suffix.split(",")[0][3:]
630+
return self.ldapadd(
631+
"\n".join(
632+
[
633+
"dn: " + self.suffix,
634+
"objectClass: dcObject",
635+
"objectClass: organization",
636+
"dc: " + suffix_dc,
637+
"o: " + suffix_dc,
638+
"",
639+
"dn: " + self.root_dn,
640+
"objectClass: applicationProcess",
641+
"cn: " + self.root_cn,
642+
]
643+
)
644+
+ "\n"
645+
)

tests/test_slapdobject.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,9 @@ def test_commands():
3535
)
3636
server.ldapsearch("ou=home", "dc=slapd-test,dc=python-ldap,dc=org", expected=32)
3737

38+
server.init_tree()
39+
3840
ldif = (
39-
"dn: dc=slapd-test,dc=python-ldap,dc=org\n"
40-
"objectClass: dcObject\n"
41-
"objectClass: organization\n"
42-
"dc: slapd-test\n"
43-
"o: slapd-test\n"
44-
"\n"
45-
"dn: cn=Manager,dc=slapd-test,dc=python-ldap,dc=org\n"
46-
"objectClass: applicationProcess\n"
47-
"cn: Manager\n"
48-
"\n"
4941
"dn: ou=home,dc=slapd-test,dc=python-ldap,dc=org\n"
5042
"objectClass: organizationalUnit\n"
5143
"ou: home\n"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy