summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2017-09-06 14:54:44 +0200
committerLukas Slebodnik <lslebodn@redhat.com>2017-10-16 15:11:43 +0200
commitebbd9a2b551feffd2040f35d938f6800fba1b278 (patch)
treea9b05ccaf60e80c274ac128dbbbe52060548071b
parentd82741b1a8ada493ca74efa5d5c8b731412d035c (diff)
downloadsssd-ebbd9a2b551feffd2040f35d938f6800fba1b278.tar.gz
sssd-ebbd9a2b551feffd2040f35d938f6800fba1b278.tar.xz
sssd-ebbd9a2b551feffd2040f35d938f6800fba1b278.zip
ds_openldap: Extract functionality to protected methods
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/tests/intg/ds_openldap.py51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/tests/intg/ds_openldap.py b/src/tests/intg/ds_openldap.py
index 6a074c947..b7e0eb6c4 100644
--- a/src/tests/intg/ds_openldap.py
+++ b/src/tests/intg/ds_openldap.py
@@ -185,26 +185,10 @@ class DSOpenLDAP(DS):
db_config_file.write(db_config)
db_config_file.close()
- def setup(self):
- """Setup the instance."""
- ldapi_socket = self.run_dir + "/ldapi"
- ldapi_url = "ldapi://" + url_quote(ldapi_socket, "")
- url_list = ldapi_url + " " + self.ldap_url
-
- os.makedirs(self.conf_slapd_d_dir)
- os.makedirs(self.run_dir)
- os.makedirs(self.data_dir)
-
- #
- # Setup initial configuration
- #
- self._setup_config()
-
- #
- # Start the daemon
- #
+ def _start_daemon(self):
+ """Start the instance."""
if subprocess.call(["slapd", "-F", self.conf_slapd_d_dir,
- "-h", url_list]) != 0:
+ "-h", self.url_list]) != 0:
raise Exception("Failed to start slapd")
#
@@ -213,7 +197,7 @@ class DSOpenLDAP(DS):
attempt = 0
while True:
try:
- ldap_conn = ldap.initialize(ldapi_url)
+ ldap_conn = ldap.initialize(self.ldapi_url)
ldap_conn.simple_bind_s(self.admin_rdn + ",cn=config",
self.admin_pw)
ldap_conn.unbind_s()
@@ -228,6 +212,23 @@ class DSOpenLDAP(DS):
raise Exception("Failed to start slapd")
time.sleep(1)
+ def setup(self):
+ """Setup the instance."""
+ ldapi_socket = self.run_dir + "/ldapi"
+ self.ldapi_url = "ldapi://" + url_quote(ldapi_socket, "")
+ self.url_list = self.ldapi_url + " " + self.ldap_url
+
+ os.makedirs(self.conf_slapd_d_dir)
+ os.makedirs(self.run_dir)
+ os.makedirs(self.data_dir)
+
+ #
+ # Setup initial configuration
+ #
+ self._setup_config()
+
+ self._start_daemon()
+
#
# Relax requirement of member attribute presence in groupOfNames
#
@@ -243,7 +244,7 @@ class DSOpenLDAP(DS):
b"STRUCTURAL MUST ( cn ) MAY ( member $ businessCategory $ "
b"seeAlso $ owner $ ou $ o $ description ) )"),
]
- ldap_conn = ldap.initialize(ldapi_url)
+ ldap_conn = ldap.initialize(self.ldapi_url)
ldap_conn.simple_bind_s(self.admin_rdn + ",cn=config", self.admin_pw)
ldap_conn.modify_s("cn={0}core,cn=schema,cn=config", modlist)
ldap_conn.unbind_s()
@@ -266,8 +267,8 @@ class DSOpenLDAP(DS):
])
ldap_conn.unbind_s()
- def teardown(self):
- """Teardown the instance."""
+ def _stop_daemon(self):
+ """Stop the instance."""
# Wait for slapd to stop
try:
pid_file = open(self.pid_path, "r")
@@ -285,5 +286,9 @@ class DSOpenLDAP(DS):
if e.errno != errno.ENOENT:
raise
+ def teardown(self):
+ """Teardown the instance."""
+ self._stop_daemon()
+
for path in (self.conf_slapd_d_dir, self.run_dir, self.data_dir):
shutil.rmtree(path, True)