Home | History | Annotate | Line # | Download | only in scripts
test026-dn revision 1.1.1.2
      1 #! /bin/sh
      2 # OpenLDAP: pkg/ldap/tests/scripts/test026-dn,v 1.13.2.6 2009/01/22 00:01:19 kurt Exp
      3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4 ##
      5 ## Copyright 2004-2009 The OpenLDAP Foundation.
      6 ## All rights reserved.
      7 ##
      8 ## Redistribution and use in source and binary forms, with or without
      9 ## modification, are permitted only as authorized by the OpenLDAP
     10 ## Public License.
     11 ##
     12 ## A copy of this license is available in the file LICENSE in the
     13 ## top-level directory of the distribution or, alternatively, at
     14 ## <http://www.OpenLDAP.org/license.html>.
     15 
     16 echo "running defines.sh"
     17 . $SRCDIR/scripts/defines.sh
     18 
     19 mkdir -p $TESTDIR $DBDIR1
     20 
     21 . $CONFFILTER $BACKEND $MONITORDB < $DNCONF > $CONF1
     22 echo "Starting slapd on TCP/IP port $PORT1..."
     23 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     24 PID=$!
     25 if test $WAIT != 0 ; then
     26     echo PID $PID
     27     read foo
     28 fi
     29 KILLPIDS="$PID"
     30 
     31 sleep 1
     32 
     33 echo "Testing slapd DN parsing..."
     34 for i in 0 1 2 3 4 5; do
     35 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     36 		'objectclass=*' > /dev/null 2>&1
     37 	RC=$?
     38 	if test $RC = 0 ; then
     39 		break
     40 	fi
     41 	echo "Waiting 5 seconds for slapd to start..."
     42 	sleep 5
     43 done
     44 
     45 if test $RC != 0 ; then
     46 	echo "ldapsearch failed ($RC)!"
     47 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     48 	exit $RC
     49 fi
     50 
     51 echo "Loading database..."
     52 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \
     53 	$TESTOUT 2>&1
     54 
     55 cat /dev/null > $SEARCHOUT
     56 
     57 echo "Searching database..."
     58 echo "# Searching database..." >> $SEARCHOUT
     59 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 >> $SEARCHOUT 2>&1
     60 
     61 RC=$?
     62 if test $RC != 0 ; then
     63 	echo "ldapsearch failed ($RC)!"
     64 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     65 	exit $RC
     66 fi
     67 
     68 DN="OU=Sales+CN=J. Smith,DC=example,DC=net"
     69 echo "Searching database for DN=\"$DN\"..."
     70 echo "# Searching database for DN=\"$DN\"..." >> $SEARCHOUT
     71 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
     72 	"(member=$DN)" >> $SEARCHOUT 2>&1
     73 
     74 RC=$?
     75 if test $RC != 0 ; then
     76 	echo "ldapsearch failed ($RC)!"
     77 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     78 	exit $RC
     79 fi
     80 
     81 DN="testUUID=597ae2f6-16a6-1027-98f4-ABCDEFabcdef,DC=Example"
     82 echo "Searching database for entryUUID-named DN=\"$DN\"..."
     83 echo "# Searching database for entryUUID-named DN=\"$DN\"..." >> $SEARCHOUT
     84 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
     85 	"(member=$DN)" \
     86 	>> $SEARCHOUT 2>&1
     87 
     88 RC=$?
     89 if test $RC != 0 ; then
     90 	echo "ldapsearch failed ($RC)!"
     91 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     92 	exit $RC
     93 fi
     94 
     95 DN="dc=example,dc=com"
     96 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
     97 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
     98 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
     99 	"(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
    100 
    101 RC=$?
    102 if test $RC != 0 ; then
    103 	echo "ldapsearch failed ($RC)!"
    104 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    105 	exit $RC
    106 fi
    107 
    108 DN="dc=example,dc=com#'001000'B"
    109 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
    110 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
    111 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    112 	"(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
    113 
    114 RC=$?
    115 if test $RC != 0 ; then
    116 	echo "ldapsearch failed ($RC)!"
    117 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    118 	exit $RC
    119 fi
    120 
    121 DN="dc=example,dc=com#'1000'B"
    122 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
    123 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
    124 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    125 	"(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
    126 
    127 RC=$?
    128 if test $RC != 0 ; then
    129 	echo "ldapsearch failed ($RC)!"
    130 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    131 	exit $RC
    132 fi
    133 
    134 DN="dc=example,dc=com"
    135 echo "Searching database for uniqueMember~=\"$DN\" (approx)..."
    136 echo "# Searching database for uniqueMember~=\"$DN\" (approx)..." >> $SEARCHOUT
    137 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    138 	"(uniqueMember~=)" >> $SEARCHOUT 2>&1
    139 
    140 RC=$?
    141 if test $RC != 0 ; then
    142 	echo "ldapsearch failed ($RC)!"
    143 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    144 	exit $RC
    145 fi
    146 
    147 DN="dc=example,dc=com#'1000'B"
    148 echo "Searching database for uniqueMember~=\"$DN\" (approx)..."
    149 echo "# Searching database for uniqueMember~=\"$DN\" (approx)..." >> $SEARCHOUT
    150 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    151 	"(uniqueMember~=$DN)" >> $SEARCHOUT 2>&1
    152 
    153 RC=$?
    154 if test $RC != 0 ; then
    155 	echo "ldapsearch failed ($RC)!"
    156 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    157 	exit $RC
    158 fi
    159 
    160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
    161 
    162 echo "Filtering ldapsearch results..."
    163 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    164 echo "Filtering original data..."
    165 . $LDIFFILTER < $DNOUT > $LDIFFLT
    166 echo "Comparing ldapsearch results against original..."
    167 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    168 
    169 if test $? != 0 ; then
    170 	echo "comparison failed - DN write operations did not complete correctly"
    171 	exit 1
    172 fi
    173 
    174 #####
    175 
    176 echo ">>>>> Test succeeded"
    177 
    178 test $KILLSERVERS != no && wait
    179 
    180 exit 0
    181