summaryrefslogtreecommitdiffstats
path: root/src/tests/intg/ds.py
diff options
context:
space:
mode:
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>2014-11-24 19:13:16 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-05-28 13:55:52 +0200
commit9d453f1e8b28983b363b44c49b7cd701a994fd97 (patch)
treef681e8183b68cfcca3e7b618b119238489b46cce /src/tests/intg/ds.py
parent9c5e4ae08ea41f9b1cdb3b3d0e9c35056baeab86 (diff)
downloadsssd-9d453f1e8b28983b363b44c49b7cd701a994fd97.tar.gz
sssd-9d453f1e8b28983b363b44c49b7cd701a994fd97.tar.xz
sssd-9d453f1e8b28983b363b44c49b7cd701a994fd97.zip
Add integration tests
Add "intgcheck" make target. Update CI to use it. The "intgcheck" target configures and builds sssd in a sub-directory, installs it into a prefix in another sub-directory, and then makes the "intgcheck-installed" target from within src/tests/intg in that separate build. The "intgcheck-installed" target in src/tests/intg runs py.test for all tests it can find in that directory, under fakeroot and nss_wrapper/uid_wrapper environments emulating running under root. It also adds the value of INTGCHECK_PYTEST_ARGS environment/make variable to the py.test command line. You can use it to pass additional py.test options, such as specifying a subset of tests to run. See "py.test --help" output. There are only two test suites in src/tests/intg at the moment: ent_test.py and ldap_test.py. The ent_test.py runs tests on ent.py - a module of assertion functions for checking entries in NSS database (passwd and group), for use in actual tests. The ent_test.py suite can be used as ent.py usage reference. The ldap_test.py suite sets up and starts a slapd instance, adds a few user and group entries, configures and starts sssd and verifies that those users and groups are retrieved correctly using various NSS functions. The tests are very basic at the moment. Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/tests/intg/ds.py')
-rw-r--r--src/tests/intg/ds.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/tests/intg/ds.py b/src/tests/intg/ds.py
new file mode 100644
index 000000000..a87190275
--- /dev/null
+++ b/src/tests/intg/ds.py
@@ -0,0 +1,61 @@
+#
+# Abstract directory server instance class
+#
+# Copyright (c) 2015 Red Hat, Inc.
+# Author: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import ldap
+
+class DS:
+ """Abstract directory server instance."""
+
+ def __init__(self, dir, port, base_dn, admin_rdn, admin_pw):
+ """
+ Initialize the instance.
+
+ Arguments:
+ dir Path to the root of the filesystem hierarchy to create
+ the instance under.
+ port TCP port on localhost to bind the server to.
+ base_dn Base DN.
+ admin_rdn Administrator DN, relative to BASE_DN.
+ admin_pw Administrator password.
+ """
+ self.dir = dir
+ self.port = port
+ self.ldap_url = "ldap://localhost:" + str(self.port)
+ self.base_dn = base_dn
+ self.admin_rdn = admin_rdn
+ self.admin_dn = admin_rdn + "," + base_dn
+ self.admin_pw = admin_pw
+
+ def setup(self):
+ """Setup the instance"""
+ raise NotImplementedError()
+
+ def teardown(self):
+ """Teardown the instance"""
+ raise NotImplementedError()
+
+ def bind(self):
+ """Connect to the server and bind as admin, return connection."""
+ conn = ldap.initialize(self.ldap_url)
+ conn.simple_bind_s(self.admin_dn, self.admin_pw)
+ return conn
+
+ def __del__(self):
+ """Destroy the instance."""
+ self.teardown()