3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 mkdir -p $TESTDIR $DBDIR1
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
23 $SLAPADD -f $CONF1 -l $LDIFORDERED
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
33 if test $WAIT != 0 ; then
41 echo "Testing slapd Manage operations..."
42 for i in 0 1 2 3 4 5; do
43 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
44 'objectclass=*' > /dev/null 2>&1
46 if test $RC = 0 ; then
49 echo "Waiting 5 seconds for slapd to start..."
53 if test $RC != 0 ; then
54 echo "ldapsearch failed ($RC)!"
55 test $KILLSERVERS != no && kill -HUP $KILLPIDS
59 echo "Testing modify, add, and delete..."
60 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
62 $TESTOUT 2>&1 << EOMODS
72 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
74 # add obsolete auxiliary objectclass
77 objectClass: obsoletePerson
79 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
81 # add obsolete attribute
87 # create/modify timestamp test
90 dn: ou=Groups,dc=example,dc=com
94 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
96 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
97 # change modifiersName
99 replace: modifiersName
100 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
102 dn: dc=example,dc=com
105 replace: modifyTimestamp
106 modifyTimestamp: 19700101000000Z
108 replace: createTimestamp
109 createTimestamp: 19700101000000Z
112 dn: cn=All Staff,ou=Groups,dc=example,dc=com
116 entryUUID: badbadba-dbad-1029-92f7-badbadbadbad
118 dn: cn=All Staff,dc=example,dc=com
120 objectClass: groupOfNames
123 creatorsName: cn=Someone
124 createTimestamp: 19700101000000Z
125 modifiersName: cn=Someone Else
126 modifyTimestamp: 19700101000000Z
127 entryUUID: badbadef-dbad-1029-92f7-badbadbadbad
131 if test $RC != 0 ; then
132 echo "ldapmodify failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Testing modify, add, and delete..."
138 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
140 $TESTOUT 2>&1 << EOMODS
146 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
148 # update structural object class of entry via objectClass replace
151 objectClass: obsoletePerson
153 replace: structuralObjectClass
154 structuralObjectClass: testPerson
156 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
157 # update structural object class of entry via objectClass add
160 objectClass: testPerson
162 replace: structuralObjectClass
163 structuralObjectClass: testPerson
165 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
166 # update structural object class of entry via objectClass delete/add
169 objectClass: OpenLDAPperson
172 objectClass: testPerson
174 delete: structuralObjectClass
176 add: structuralObjectClass
177 structuralObjectClass: testPerson
181 if test $RC != 0 ; then
182 echo "ldapmodify failed ($RC)! IGNORED"
183 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 echo "Using ldapsearch to retrieve all the entries..."
188 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
189 'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
191 if test $RC != 0 ; then
192 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "ldapsearch failed ($RC)!"
197 $LDAPSEARCH -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
198 'objectClass=*' '*' creatorsName createTimestamp \
199 modifiersName modifyTimestamp >> $SEARCHOUT 2>&1
201 if test $RC != 0 ; then
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 echo "ldapsearch failed ($RC)!"
207 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
208 '(cn=All Staff)' '*' entryUUID >> $SEARCHOUT 2>&1
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
218 echo "Filtering ldapsearch results..."
219 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
220 echo "Filtering original ldif used to create database..."
221 . $LDIFFILTER < $LDIF > $LDIFFLT
222 echo "Comparing filter output..."
223 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
225 if test $? != 0 ; then
226 echo "comparison failed - manage operations did not complete correctly"
230 echo ">>>>> Test succeeded"
232 test $KILLSERVERS != no && wait