summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource4/script/tests/mktestsetup.sh82
-rwxr-xr-xsource4/script/tests/selftest.sh16
-rwxr-xr-xsource4/script/tests/test_functions.sh10
3 files changed, 102 insertions, 6 deletions
diff --git a/source4/script/tests/mktestsetup.sh b/source4/script/tests/mktestsetup.sh
index eaa332035d..1814e960fd 100755
--- a/source4/script/tests/mktestsetup.sh
+++ b/source4/script/tests/mktestsetup.sh
@@ -19,6 +19,8 @@ fi
DOMAIN=SAMBADOMAIN
USERNAME=administrator
REALM=SAMBA.EXAMPLE.COM
+DNSNAME="samba.example.com"
+BASEDN="dc=samba,dc=example,dc=com"
PASSWORD=penguin
SRCDIR=`pwd`
ROOT=$USER
@@ -57,11 +59,15 @@ CERTFILE=$TLSDIR/cert.pem
KEYFILE=$TLSDIR/key.pem
WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket
CONFIGURATION="--configfile=$CONFFILE"
+LDAPDIR=$PREFIX_ABS/ldap
+SLAPD_CONF=$LDAPDIR/slapd.conf
export CONFIGURATION
export CONFFILE
+export SLAPD_CONF
+export PIDDIR
rm -rf $PREFIX/*
-mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR
+mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR $LDAPDIR/db
cat >$CONFFILE<<EOF
[global]
@@ -200,6 +206,7 @@ cat >$KRB5_CONFIG<<EOF
[domain_realm]
.samba.example.com = SAMBA.EXAMPLE.COM
EOF
+export KRB5_CONFIG
cat >$DHFILE<<EOF
-----BEGIN DH PARAMETERS-----
@@ -267,11 +274,75 @@ cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
EOF
-export KRB5_CONFIG
+cat >$SLAPD_CONF <<EOF
+loglevel 0
+
+include $LDAPDIR/ad.schema
+
+pidfile $PIDDIR/slapd.pid
+argsfile $LDAPDIR/slapd.args
+
+access to * by * write
+
+allow update_anon bind_anon_dn
+
+include $LDAPDIR/modules.conf
+
+defaultsearchbase "$BASEDN"
+
+backend bdb
+database bdb
+suffix "$BASEDN"
+directory $LDAPDIR/db
+index objectClass eq
+index samAccountName eq
+
+EOF
+
+PROVISION_OPTIONS="$CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1"
+PROVISION_OPTIONS="$PROVISION_OPTIONS --quiet --domain $DOMAIN --realm $REALM"
+PROVISION_OPTIONS="$PROVISION_OPTIONS --adminpass $PASSWORD --root=$ROOT"
+$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS
+
+LDAPI="ldapi://$LDAPDIR/ldapi"
+LDAPI_ESCAPE="ldapi://"`echo $LDAPDIR/ldapi | sed 's|/|%2F|g'`
+export LDAPI
+export LDAPI_ESCAPE
+
+#This uses the provision we just did, to read out the schema
+$srcdir/bin/ad2oLschema $CONFIGURATION -H $PRIVATEDIR/sam.ldb -I $srcdir/setup/schema-map-openldap-2.3 -O $LDAPDIR/ad.schema
+#Now create an LDAP baseDN
+$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-base
+
+OLDPATH=$PATH
+PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
+export PATH
+
+MODCONF=$LDAPDIR/modules.conf
+rm -f $MODCONF
+touch $MODCONF
+
+if ! slaptest -u -f $SLAPD_CONF > /dev/null 2>&1; then
+ echo "enabling slapd modules"
+ cat > $MODCONF <<EOF
+modulepath /usr/lib/ldap
+moduleload back_bdb
+EOF
+fi
+
+if slaptest -u -f $SLAPD_CONF; then
+ if ! slapadd -f $SLAPD_CONF < $PRIVATEDIR/$DNSNAME.ldif; then
+ echo "slapadd failed"
+ fi
+
+ if ! slaptest -f $SLAPD_CONF; then
+ echo "slaptest after database load failed"
+ fi
+fi
+
+PATH=$OLDPATH
+export PATH
-$srcdir/bin/smbscript $srcdir/setup/provision $CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1 \
- --quiet --domain $DOMAIN --realm $REALM \
- --adminpass $PASSWORD --root=$ROOT || exit 1
cat >$PRIVATEDIR/wins_config.ldif<<EOF
dn: name=TORTURE_26,CN=PARTNERS
@@ -284,3 +355,4 @@ type: 0x3
EOF
$srcdir/bin/ldbadd -H $PRIVATEDIR/wins_config.ldb < $PRIVATEDIR/wins_config.ldif >/dev/null || exit 1
+
diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh
index e28aaf60df..b09399f032 100755
--- a/source4/script/tests/selftest.sh
+++ b/source4/script/tests/selftest.sh
@@ -3,7 +3,7 @@
if [ $# -lt 1 ]
then
- echo "$0 PREFIX"
+ echo "$0 PREFIX TESTS"
exit
fi
@@ -54,6 +54,16 @@ fi
incdir=`dirname $ARG0`
. $incdir/test_functions.sh
+#Start slapd before smbd
+if [ x"$TEST_LDAP" = x"yes" ]; then
+ slapd_start
+ echo -n "LDAP PROVISIONING..."
+ if ! $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI; then
+ echo "LDAP PROVISIONING failed: $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI"
+ exit 1;
+ fi
+fi
+
SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
export SMBD_TEST_FIFO
SMBD_TEST_LOG="$PREFIX/smbd_test.log"
@@ -100,6 +110,10 @@ failed=$?
kill `cat $PIDDIR/smbd.pid`
+if [ "$TEST_LDAP"x = "yesx" ]; then
+ kill `cat $PIDDIR/slapd.pid`
+fi
+
END=`date`
echo "START: $START ($ARG0)";
echo "END: $END ($ARG0)";
diff --git a/source4/script/tests/test_functions.sh b/source4/script/tests/test_functions.sh
index f92f4c6632..9efe204a35 100755
--- a/source4/script/tests/test_functions.sh
+++ b/source4/script/tests/test_functions.sh
@@ -65,6 +65,16 @@ smbd_have_test_log() {
return 1;
}
+slapd_start() {
+ OLDPATH=$PATH
+ PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
+ export PATH
+ slapd -f $SLAPD_CONF -h $LDAPI_ESCAPE
+ PATH=$OLDPATH
+ export PATH
+ return 0;
+}
+
testit() {
if [ -z "$PREFIX" ]; then
PREFIX=test_prefix