test001-ciboolean revision 1.1.1.1 1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 The OpenLDAP Foundation.
6 ## Copyright 2022 Symas Corp.
7 ##
8 ## All rights reserved.
9 ##
10 ## Redistribution and use in source and binary forms, with or without
11 ## modification, are permitted only as authorized by the OpenLDAP
12 ## Public License.
13 ##
14 ## A copy of this license is available in the file LICENSE in the
15 ## top-level directory of the distribution or, alternatively, at
16 ## <http://www.OpenLDAP.org/license.html>.
17 ##
18 ## ACKNOWLEDGEMENTS:
19 ## This work was developed in 2022 by Nadezhda Ivanova for Symas Corp.
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
22
23 echo ""
24
25 rm -rf $TESTDIR
26
27 mkdir -p $TESTDIR $DBDIR1
28
29 echo "Starting slapd on TCP/IP port $PORT1..."
30 . $CONFFILTER $BACKEND < data/slapd.conf > $CONF1
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
32 PID=$!
33 if test $WAIT != 0 ; then
34 echo PID $PID
35 read foo
36 fi
37 KILLPIDS="$PID"
38
39 sleep 1
40
41 echo "Using ldapsearch to check that slapd is running..."
42 for i in 0 1 2 3 4 5; do
43 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
44 'objectclass=*' > /dev/null 2>&1
45 RC=$?
46 if test $RC = 0 ; then
47 break
48 fi
49 echo "Waiting 5 seconds for slapd to start..."
50 sleep 5
51 done
52 if test $RC != 0 ; then
53 echo "ldapsearch failed ($RC)!"
54 test $KILLSERVERS != no && kill -HUP $KILLPIDS
55 exit $RC
56 fi
57
58 echo "Using ldapadd to populate the database..."
59 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
60 data/test001-add.ldif > $TESTOUT 2>&1
61 RC=$?
62 if test $RC != 0 ; then
63 echo "ldapadd failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
65 exit $RC
66 fi
67
68 cat /dev/null > $SEARCHOUT
69
70 echo "Searching base=\"$BASEDN\"..."
71 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
72 $LDAPSEARCH -S "" -H $URI1 -b "$BASEDN" >> $SEARCHOUT 2>&1
73 RC=$?
74
75 if test $RC != 0 ; then
76 echo "Search failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 exit $RC
79 fi
80
81 echo "Filtering ldapsearch results..."
82 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
83 echo "Filtering original ldif used to create database..."
84 $LDIFFILTER < data/test001-add.ldif > $LDIFFLT
85 echo "Comparing filter output..."
86 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
87
88 if test $? != 0 ; then
89 echo "comparison failed - database population didn't succeed"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 exit 1
92 fi
93
94 #
95 # Do some modifications
96 #
97
98 echo "Modifying database \"$BASEDN\" with TRUE..."
99 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -H $URI1 -w $PASSWD \
100 -M >> $TESTOUT 2>&1 << EOMODS
101 dn: cn=user01,ou=people,$BASEDN
102 changetype: modify
103 replace: IsBusy
104 IsBusy: TRUE
105 EOMODS
106
107 RC=$?
108 if test $RC != 0 ; then
109 echo "Modify failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 exit $RC
112 fi
113
114 echo "Modifying database \"$BASEDN\" with false..."
115 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -H $URI1 -w $PASSWD \
116 -M >> $TESTOUT 2>&1 << EOMODS
117 dn: cn=user06,ou=people,$BASEDN
118 changetype: modify
119 replace: IsBusy
120 IsBusy: false
121 EOMODS
122
123 RC=$?
124 if test $RC != 0 ; then
125 echo "Modify failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 exit $RC
128 fi
129
130 echo "Modifying database \"$BASEDN\"with TRUA..."
131 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -H $URI1 -w $PASSWD \
132 -M >> $TESTOUT 2>&1 << EOMODS
133 dn: cn=user02,ou=people,$BASEDN
134 changetype: modify
135 replace: IsBusy
136 IsBusy: TRUA
137
138 EOMODS
139
140 RC=$?
141 if test $RC != 21 ; then
142 echo "Modify with an incorrect value failed ($RC)!"
143 test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 exit $RC
145 fi
146
147 cat /dev/null > $SEARCHOUT
148
149 echo " base=\"$BASEDN\"..."
150 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
151 $LDAPSEARCH -S "" -H $URI1 -b "$BASEDN" -M "(IsBusy=false)" '*' ref \
152 >> $SEARCHOUT 2>&1
153
154 RC=$?
155 if test $RC != 0 ; then
156 echo "Search failed ($RC)!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 exit $RC
159 fi
160
161
162 echo "Filtering ldapsearch results..."
163 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
164 echo "Filtering partial ldif used to create database..."
165 $LDIFFILTER < data/test001-search_1.ldif > $LDIFFLT
166 echo "Comparing filter output..."
167 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
168
169 if test $? != 0 ; then
170 echo "comparison failed - search for (IsBusy=false) didn't succeed"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 exit 1
173 fi
174
175 cat /dev/null > $SEARCHOUT
176
177 echo " base=\"$BASEDN\"..."
178 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
179 $LDAPSEARCH -S "" -H $URI1 -b "$BASEDN" -M "(IsBusy=TRUE)" '*' ref \
180 >> $SEARCHOUT 2>&1
181 RC=$?
182 if test $RC != 0 ; then
183 echo "Search failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 exit $RC
186 fi
187
188
189 echo "Filtering ldapsearch results..."
190 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
191 echo "Filtering partial ldif used to create database..."
192 $LDIFFILTER < data/test001-search_2.ldif > $LDIFFLT
193 echo "Comparing filter output..."
194 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
195
196 if test $? != 0 ; then
197 echo "comparison failed - search for (IsBusy=TRUE) didn't succeed"
198 test $KILLSERVERS != no && kill -HUP $KILLPIDS
199 exit 1
200 fi
201
202 echo "Modifying cn=config, setting olcReadOnly to True"
203 $LDAPMODIFY -v -D "cn=manager,cn=config" -H $URI1 -w $PASSWD \
204 -M >> $TESTOUT 2>&1 << EOMODS
205 dn: olcDatabase={1}mdb,cn=config
206 changetype: modify
207 replace: olcReadOnly
208 olcReadOnly: True
209 EOMODS
210
211 RC=$?
212 if test $RC != 0 ; then
213 echo "Modify failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 exit $RC
216 fi
217
218 echo "Modifying database \"$BASEDN\" to verify olcReadOnly value"
219 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -H $URI1 -w $PASSWD \
220 -M >> $TESTOUT 2>&1 << EOMODS
221 dn: cn=user06,ou=people,$BASEDN
222 changetype: modify
223 replace: IsBusy
224 IsBusy: false
225 EOMODS
226
227 RC=$?
228 if test $RC != 53 ; then
229 echo "Modify failed ($RC)!"
230 test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 exit $RC
232 fi
233
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235
236 echo ">>>>> Test succeeded"
237
238 test $KILLSERVERS != no && wait
239
240 exit 0
241