]> git.sur5r.net Git - openldap/blob - tests/scripts/test026-dn
0dfb6fff701351921df4d107c0cd94cfd2e70af7
[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 RC=$?
54 if test $RC != 0 ; then
55         echo "ldapadd failed ($RC)!"
56         test $KILLSERVERS != no && kill -HUP $KILLPIDS
57         exit $RC
58 fi
59
60 echo "Searching database..."
61 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
62
63 RC=$?
64 if test $RC != 0 ; then
65         echo "ldapsearch failed ($RC)!"
66         test $KILLSERVERS != no && kill -HUP $KILLPIDS
67         exit $RC
68 fi
69
70 echo "Searching database for DN..."
71 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
72         "(member=OU=Sales+CN=J. Smith,DC=example,DC=net)" >> $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 echo "Searching database for uniqueMember..."
82 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
83         "(uniqueMember=dc=example,dc=com)" >> $SEARCHOUT 2>&1
84
85 RC=$?
86 if test $RC != 0 ; then
87         echo "ldapsearch failed ($RC)!"
88         test $KILLSERVERS != no && kill -HUP $KILLPIDS
89         exit $RC
90 fi
91
92 echo "Searching database for uniqueMember..."
93 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
94         "(uniqueMember=dc=example,dc=com#'001000'B)" >> $SEARCHOUT 2>&1
95
96 RC=$?
97 if test $RC != 0 ; then
98         echo "ldapsearch failed ($RC)!"
99         test $KILLSERVERS != no && kill -HUP $KILLPIDS
100         exit $RC
101 fi
102
103 echo "Searching database for uniqueMember (approx) ..."
104 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
105         "(uniqueMember~=dc=example,dc=com)" >> $SEARCHOUT 2>&1
106
107 RC=$?
108 if test $RC != 0 ; then
109         echo "ldapsearch failed ($RC)!"
110         test $KILLSERVERS != no && kill -HUP $KILLPIDS
111         exit $RC
112 fi
113
114 echo "Searching database for uniqueMember (approx) ..."
115 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
116         "(uniqueMember~=dc=example,dc=com#'001000'B)" >> $SEARCHOUT 2>&1
117
118 RC=$?
119 if test $RC != 0 ; then
120         echo "ldapsearch failed ($RC)!"
121         test $KILLSERVERS != no && kill -HUP $KILLPIDS
122         exit $RC
123 fi
124
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126
127 LDIFOUT=$DNOUT
128
129 echo "Filtering ldapsearch results..."
130 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
131 echo "Comparing ldapsearch results against original..."
132 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
133
134 if test $? != 0 ; then
135         echo "comparison failed - DN write operations did not complete correctly"
136         exit 1
137 fi
138
139 #####
140
141 echo ">>>>> Test succeeded"
142 exit 0