summaryrefslogtreecommitdiffstats
path: root/tests/helpers/common.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-03-17 20:25:18 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2015-03-23 15:44:25 +0100
commitcacb41e93b377496e77f824f4f1b0ce206da0bed (patch)
treee3f08b34d1480099eb1aca84ad25e0324bf16c22 /tests/helpers/common.py
parent521a28fd446a64c4fa5895e1aa768512249652f6 (diff)
downloadipsilon-cacb41e93b377496e77f824f4f1b0ce206da0bed.tar.gz
ipsilon-cacb41e93b377496e77f824f4f1b0ce206da0bed.tar.xz
ipsilon-cacb41e93b377496e77f824f4f1b0ce206da0bed.zip
Add LDAP test
This finally tests the LDAP login/info plugins as well as the special "groups" attribute. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'tests/helpers/common.py')
-rwxr-xr-xtests/helpers/common.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/helpers/common.py b/tests/helpers/common.py
index 56ea9ff..07a41fe 100755
--- a/tests/helpers/common.py
+++ b/tests/helpers/common.py
@@ -145,6 +145,26 @@ class IpsilonTestBase(object):
cmd = ['/usr/bin/createdb', '-h', addr, '-p', port, d]
subprocess.check_call(cmd, env=env)
+ def setup_ldap(self, env):
+ ldapdir = os.path.join(self.testdir, 'ldap')
+ os.mkdir(ldapdir)
+ with open(os.path.join(self.rootdir, 'tests/slapd.conf')) as f:
+ t = Template(f.read())
+ text = t.substitute({'ldapdir': ldapdir})
+ filename = os.path.join(ldapdir, 'slapd.conf')
+ with open(filename, 'w+') as f:
+ f.write(text)
+ subprocess.check_call(['/usr/sbin/slapadd', '-f', filename, '-l',
+ 'tests/ldapdata.ldif'], env=env)
+
+ return filename
+
+ def start_ldap_server(self, conf, addr, port, env):
+ p = subprocess.Popen(['/usr/sbin/slapd', '-d', '0', '-f', conf,
+ '-h', 'ldap://%s:%s' % (addr, port)],
+ env=env, preexec_fn=os.setsid)
+ self.processes.append(p)
+
def wait(self):
for p in self.processes:
os.killpg(p.pid, signal.SIGTERM)