]> git.sur5r.net Git - openldap/blob - tests/scripts/test026-dn
Update test026 for updated uniqueMemberMatch semantics
[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 echo "Testing slapd DN parsing..."
31 for i in 0 1 2 3 4 5; do
32         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
33                 'objectclass=*' > /dev/null 2>&1
34         RC=$?
35         if test $RC = 0 ; then
36                 break
37         fi
38         echo "Waiting 5 seconds for slapd to start..."
39         sleep 5
40 done
41
42 if test $RC != 0 ; then
43         echo "ldapsearch failed ($RC)!"
44         test $KILLSERVERS != no && kill -HUP $KILLPIDS
45         exit $RC
46 fi
47
48 echo "Loading database..."
49 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \
50         /dev/null 2>&1
51
52 echo "Searching database..."
53 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
54
55 RC=$?
56 if test $RC != 0 ; then
57         echo "ldapsearch failed ($RC)!"
58         test $KILLSERVERS != no && kill -HUP $KILLPIDS
59         exit $RC
60 fi
61
62 echo "Searching database for DN..."
63 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
64         "(member=OU=Sales+CN=J. Smith,DC=example,DC=net)" >> $SEARCHOUT 2>&1
65
66 RC=$?
67 if test $RC != 0 ; then
68         echo "ldapsearch failed ($RC)!"
69         test $KILLSERVERS != no && kill -HUP $KILLPIDS
70         exit $RC
71 fi
72
73 echo "Searching database for uniqueMember..."
74 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
75         "(uniqueMember=dc=example,dc=com)" >> $SEARCHOUT 2>&1
76
77 RC=$?
78 if test $RC != 0 ; then
79         echo "ldapsearch failed ($RC)!"
80         test $KILLSERVERS != no && kill -HUP $KILLPIDS
81         exit $RC
82 fi
83
84 echo "Searching database for uniqueMember..."
85 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
86         "(uniqueMember=dc=example,dc=com#'001000'B)" >> $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 echo "Searching database for uniqueMember (approx) ..."
96 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
97         "(uniqueMember~=dc=example,dc=com)" >> $SEARCHOUT 2>&1
98
99 RC=$?
100 if test $RC != 0 ; then
101         echo "ldapsearch failed ($RC)!"
102         test $KILLSERVERS != no && kill -HUP $KILLPIDS
103         exit $RC
104 fi
105
106 echo "Searching database for uniqueMember (approx) ..."
107 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
108         "(uniqueMember~=dc=example,dc=com#'001000'B)" >> $SEARCHOUT 2>&1
109
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapsearch failed ($RC)!"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit $RC
115 fi
116
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118
119 LDIFOUT=$DNOUT
120
121 echo "Comparing ldapsearch results against original..."
122 $CMP $SEARCHOUT $LDIFOUT > $CMPOUT
123
124 if test $? != 0 ; then
125         echo "comparison failed - DN write operations did not complete correctly"
126         exit 1
127 fi
128
129 #####
130
131 echo ">>>>> Test succeeded"
132 exit 0