File: ldap_test

package info (click to toggle)
libuser 1%3A0.56.9.dfsg.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,604 kB
  • ctags: 1,619
  • sloc: ansic: 15,970; sh: 10,210; xml: 2,060; python: 1,740; yacc: 782; makefile: 258; sed: 16
file content (73 lines) | stat: -rwxr-xr-x 2,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /bin/sh
# Automated LDAP regression tester
#
# Copyright (c) 2004 Red Hat, Inc. All rights reserved.
#
# This is free software; you can redistribute it and/or modify it under
# the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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 Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Miloslav Trmac <mitr@redhat.com>

srcdir=$srcdir/tests

workdir=$(pwd)/test_ldap

trap 'status=$?; rm -rf "$workdir"; exit $status' 0
trap '(exit 1); exit 1' 1 2 13 15

rm -rf "$workdir"
mkdir "$workdir"

# Create a SSL key
/usr/bin/openssl req -batch -newkey rsa:512 -keyout "$workdir"/key1 -nodes \
    -x509 -days 2 -out "$workdir"/key3 <<EOF
.
.
.
.
.
localhost
.
EOF
echo > "$workdir"/key2
cat "$workdir"/key{1,2,3} > "$workdir"/key.pem
rm "$workdir"/key{1,2,3}


# Set up an LDAP server
mkdir "$workdir"/db
sed "s|@WORKDIR@|$workdir|g" < "$srcdir"/slapd.conf.in > "$workdir"/slapd.conf
# FIXME: path
/usr/sbin/slapd -h 'ldap://127.0.0.1:3890/ ldaps://127.0.0.1:6360/' \
    -f "$workdir"/slapd.conf &
sleep 3 # Time for slapd to initialize
slapd_pid=$(cat "$workdir"/slapd.pid)
trap 'status=$?; kill $slapd_pid; rm -rf "$workdir"; exit $status' 0
ldapadd -h 127.0.0.1 -p 3890 -f "$srcdir/ldap_skel.ldif" -x \
    -D cn=Manager,dc=libuser -w password


# Set up the client
LIBUSER_CONF=$workdir/libuser.conf
export LIBUSER_CONF
sed "s|@WORKDIR@|$workdir|g; s|@TOP_BUILDDIR@|$(pwd)|g" \
    < "$srcdir"/ldap.conf.in > "$LIBUSER_CONF"
# Ugly non-portable hacks
LD_LIBRARY_PATH=$(pwd)/lib/.libs
export LD_LIBRARY_PATH
PYTHONPATH=$(pwd)/python/.libs
export PYTHONPATH

# Point "$HOME/ldaprc" to "$srcdir"/ldaprc
HOME="$srcdir" python "$srcdir"/ldap_test.py