]> git.sur5r.net Git - openldap/blob - tests/scripts/test026-dn
1b5c9ac9674caae5a61c6f298ba2660fb9dcd9ef
[openldap] / tests / scripts / test026-dn
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 2004-2005 The OpenLDAP Foundation.
5 ## All rights reserved.
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
9 ## Public License.
10 ##
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
14
15 echo "running defines.sh"
16 . $SRCDIR/scripts/defines.sh
17
18 mkdir -p $TESTDIR $DBDIR1
19
20 . $CONFFILTER $BACKEND $MONITORDB < $DNCONF > $CONF1
21 echo "Starting slapd on TCP/IP port $PORT1..."
22 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
23 PID=$!
24 if test $WAIT != 0 ; then
25     echo PID $PID
26     read foo
27 fi
28 KILLPIDS="$PID"
29
30 sleep 1
31
32 echo "Testing slapd DN parsing..."
33 for i in 0 1 2 3 4 5; do
34         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
35                 'objectclass=*' > /dev/null 2>&1
36         RC=$?
37         if test $RC = 0 ; then
38                 break
39         fi
40         echo "Waiting 5 seconds for slapd to start..."
41         sleep 5
42 done
43
44 if test $RC != 0 ; then
45         echo "ldapsearch failed ($RC)!"
46         test $KILLSERVERS != no && kill -HUP $KILLPIDS
47         exit $RC
48 fi
49
50 echo "Loading database..."
51 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \
52         /dev/null 2>&1
53
54 echo "Searching database..."
55 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
56
57 RC=$?
58 if test $RC != 0 ; then
59         echo "ldapsearch failed ($RC)!"
60         test $KILLSERVERS != no && kill -HUP $KILLPIDS
61         exit $RC
62 fi
63
64 echo "Searching database for DN..."
65 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
66         "(member=OU=Sales+CN=J. Smith,DC=example,DC=net)" >> $SEARCHOUT 2>&1
67
68 RC=$?
69 if test $RC != 0 ; then
70         echo "ldapsearch failed ($RC)!"
71         test $KILLSERVERS != no && kill -HUP $KILLPIDS
72         exit $RC
73 fi
74
75 echo "Searching database for uniqueMember..."
76 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
77         "(uniqueMember=dc=example,dc=com)" >> $SEARCHOUT 2>&1
78
79 RC=$?
80 if test $RC != 0 ; then
81         echo "ldapsearch failed ($RC)!"
82         test $KILLSERVERS != no && kill -HUP $KILLPIDS
83         exit $RC
84 fi
85
86 echo "Searching database for uniqueMember..."
87 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
88         "(uniqueMember=dc=example,dc=com#'001000'B)" >> $SEARCHOUT 2>&1
89
90 RC=$?
91 if test $RC != 0 ; then
92         echo "ldapsearch failed ($RC)!"
93         test $KILLSERVERS != no && kill -HUP $KILLPIDS
94         exit $RC
95 fi
96
97 echo "Searching database for uniqueMember (approx) ..."
98 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
99         "(uniqueMember~=dc=example,dc=com)" >> $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 echo "Searching database for uniqueMember (approx) ..."
109 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
110         "(uniqueMember~=dc=example,dc=com#'001000'B)" >> $SEARCHOUT 2>&1
111
112 RC=$?
113 if test $RC != 0 ; then
114         echo "ldapsearch failed ($RC)!"
115         test $KILLSERVERS != no && kill -HUP $KILLPIDS
116         exit $RC
117 fi
118
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
120
121 LDIFOUT=$DNOUT
122
123 echo "Filtering ldapsearch results..."
124 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
125 echo "Comparing ldapsearch results against original..."
126 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
127
128 if test $? != 0 ; then
129         echo "comparison failed - DN write operations did not complete correctly"
130         exit 1
131 fi
132
133 #####
134
135 echo ">>>>> Test succeeded"
136 exit 0