]> git.sur5r.net Git - openldap/blob - tests/scripts/test005-modrdn
Add cn=monitor, cn=config, cn=schema to namingContexts.
[openldap] / tests / scripts / test005-modrdn
1 #! /bin/sh
2
3 if test $# -eq 0 ; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8 if test $# -eq 1 ; then
9         BACKEND=$1; shift
10 fi
11
12 echo "running defines.sh $SRCDIR $BACKEND"
13 . $SRCDIR/scripts/defines.sh
14
15 echo "Cleaning up in $DBDIR..."
16
17 rm -f $DBDIR/[!C]*
18
19 echo "Running ldif2ldbm to build slapd database..."
20 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
21 RC=$?
22 if test $RC != 0 ; then
23         echo "ldif2ldbm failed!"
24         exit $RC
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
29 PID=$!
30 echo "Testing slapd modrdn operations..."
31
32 # Make sure we can search the database
33 for i in 0 1 2 3 4 5; do
34         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
35                 'cn=Manager' > /dev/null 2>&1
36         RC=$?
37         if test $RC = 1 ; then
38                 echo "Waiting 5 seconds for slapd to start..."
39                 sleep 5
40         fi
41 done
42
43 if test $RC != 0 ; then
44         echo "ldapsearch failed!"
45         kill -HUP $PID
46         exit $RC
47 fi
48
49 cat /dev/null > $TESTOUT
50
51
52 # -r used to do remove of old rdn
53
54 echo "Testing modrdn(deleteoldrdn=0)..."
55 $LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
56         /dev/null 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
57
58 RC=$?
59 if test $RC != 0 ; then
60         echo "ldapmodrdn failed!"
61         kill -HUP $PID
62         exit $RC
63 fi
64
65 echo "Testing modrdn(deleteoldrdn=1)..."
66 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
67         /dev/null 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
68
69 RC=$?
70 if test $RC != 0 ; then
71         echo "ldapmodrdn failed!"
72         kill -HUP $PID
73         exit $RC
74 fi
75
76 # Ensure the new rdn's can be found
77
78 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
79 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
80             'cn=James A Jones III' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
81             > $SEARCHOUT 2>&1
82 RC=$?
83 if test $RC != 0 ; then
84         echo "ldapsearch failed!"
85         kill -HUP $PID
86         exit $RC
87 fi
88
89
90 LDIF=$MODRDNOUTMASTER1
91
92 echo "Filtering ldapsearch results..."
93 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
94 echo "Filtering original ldif used to create database..."
95 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
96 echo "Comparing filter output..."
97 cmp $SEARCHFLT $LDIFFLT
98
99 if test $? != 0 ; then
100         echo "comparison failed - modrdn operations did not complete correctly"
101         kill -HUP $PID
102         exit 1
103 fi
104
105
106 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
107 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
108             'cn=James A Jones II' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
109             >  $SEARCHOUT 2>&1
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapsearch failed!"
113         kill -HUP $PID
114         exit $RC
115 fi
116
117
118 LDIF=$MODRDNOUTMASTER2
119
120 echo "Filtering ldapsearch results..."
121 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
122 echo "Filtering original ldif used to create database..."
123 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
124 echo "Comparing filter output..."
125 cmp $SEARCHFLT $LDIFFLT
126
127 if test $? != 0 ; then
128         echo "comparison failed - modrdn operations did not complete correctly"
129         kill -HUP $PID
130         exit 1
131 fi
132
133 # Ensure that you cannot find the entry for which the rdn was deleted as
134 # an attribute.
135
136 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
137 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
138             'cn=James A Jones 2' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
139             > /dev/null 2>&1
140 RC=$?
141 if test $RC = 0 ; then
142         echo "failure: ldapsearch found attribute that was to be removed!"
143         kill -HUP $PID
144         exit $RC
145 fi
146
147 echo "Using ldapsearch to retrieve all the entries..."
148 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
149             'objectClass=*' > $SEARCHOUT 2>&1
150 RC=$?
151 if test $RC != 0 ; then
152         kill -HUP $PID
153         echo "ldapsearch failed!"
154         exit $RC
155 fi
156
157 LDIF=$MODRDNOUTMASTER0
158
159 echo "Filtering ldapsearch results..."
160 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
161 echo "Filtering original ldif used to create database..."
162 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
163 echo "Comparing filter output..."
164 cmp $SEARCHFLT $LDIFFLT
165
166 if test $? != 0 ; then
167         echo "comparison failed - modrdn operations did not complete correctly"
168         kill -HUP $PID
169         exit 1
170 fi
171
172
173 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
174 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
175         /dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones 1'
176
177 RC=$?
178 if test $RC != 0 ; then
179         echo "ldapmodrdn failed!"
180         kill -HUP $PID
181         exit $RC
182 fi
183
184 # Test that you can use modrdn with an attribute value which was previously
185 # present
186
187 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
188 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
189             'cn=James A Jones 1' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
190             >  $SEARCHOUT 2>&1
191 RC=$?
192 if test $RC != 0 ; then
193         echo "ldapsearch failed!"
194         kill -HUP $PID
195         exit $RC
196 fi
197
198
199 LDIF=$MODRDNOUTMASTER3
200
201 echo "Filtering ldapsearch results..."
202 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
203 echo "Filtering original ldif used to create database..."
204 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
205 echo "Comparing filter output..."
206 cmp $SEARCHFLT $LDIFFLT
207
208 kill -HUP $PID
209 if test $? != 0 ; then
210         echo "comparison failed - modrdn operations did not complete correctly"
211         exit 1
212 fi
213
214 echo ">>>>> Test succeeded"
215
216
217
218 # echo "modrdn test not yet written"
219
220 exit 0