]> git.sur5r.net Git - openldap/blob - tests/scripts/test037-manage
11cf238d42ffbe2752427d0956bf044a59cc9d8f
[openldap] / tests / scripts / test037-manage
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 mkdir -p $TESTDIR $DBDIR1
20
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
23 $SLAPADD -f $CONF1 -l $LDIFORDERED
24 RC=$?
25 if test $RC != 0 ; then
26         echo "slapadd failed ($RC)!"
27         exit $RC
28 fi
29
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $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 echo "Testing slapd Manage operations..."
40 for i in 0 1 2 3 4 5; do
41         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
42                 'objectclass=*' > /dev/null 2>&1
43         RC=$?
44         if test $RC = 0 ; then
45                 break
46         fi
47         echo "Waiting 5 seconds for slapd to start..."
48         sleep 5
49 done
50
51 if test $RC != 0 ; then
52         echo "ldapsearch failed ($RC)!"
53         test $KILLSERVERS != no && kill -HUP $KILLPIDS
54         exit $RC
55 fi
56
57 # ITS#3898: #ifndef LDAP_DEVEL, the control is not available
58 MANAGEDITOID="1.3.6.1.4.1.4203.666.5.12"
59 case `$LDAPSEARCH -s base -b "" -h $LOCALHOST -p $PORT1 \
60         '(supportedControl:objectIdentifierMatch:='${MANAGEDITOID}')' \
61         supportedControl | grep "supportedControl: ${MANAGEDITOID}"` in
62 "supportedControl: ${MANAGEDITOID}")
63         ;;
64 *)
65         echo "The \"manageDIT\" control appears to be unsupported; test disabled"
66         test $KILLSERVERS != no && kill -HUP $KILLPIDS
67         exit 0
68         ;;
69 esac
70
71 echo "Testing modify, add, and delete..."
72 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
73         -e \!manageDIT > \
74         $TESTOUT 2>&1 << EOMODS
75 version: 1
76 #
77 # Working Tests
78 #
79
80 #
81 # ObjectClass tests
82 #
83
84 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
85  dc=com
86 # add obsolete auxiliary objectclass
87 changetype: modify
88 add: objectClass
89 objectClass: obsoletePerson
90
91 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
92  dc=com
93 # add obsolete attribute
94 changetype: modify
95 add: testObsolete
96 testObsolete: TRUE
97
98 #
99 # create/modify timestamp test
100 #
101
102 dn: ou=Groups,dc=example,dc=com
103 # change creatorsName
104 changetype: modify
105 replace: creatorsName
106 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
107
108 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
109 # change modifiersName
110 changetype: modify
111 replace: modifiersName
112 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
113
114 EOMODS
115
116 RC=$?
117 if test $RC != 0 ; then
118         echo "ldapmodify failed ($RC)!"
119         test $KILLSERVERS != no && kill -HUP $KILLPIDS
120         exit $RC
121 fi
122
123 echo "Testing modify, add, and delete..."
124 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
125         -e \!manageDIT > \
126         $TESTOUT 2>&1 << EOMODS
127 version: 1
128 #
129 # Non-working tests
130 #
131
132 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
133  dc=com
134 # update structural object class of entry via objectClass replace
135 changetype: modify
136 replace: objectClass
137 objectClass: obsoletePerson
138 -
139 replace: structuralObjectClass
140 structuralObjectClass: testPerson
141
142 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
143 # update structural object class of entry via objectClass add
144 changetype: modify
145 add: objectClass
146 objectClass: testPerson
147 -
148 replace: structuralObjectClass
149 structuralObjectClass: testPerson
150
151 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
152 # update structural object class of entry via objectClass delete/add
153 changetype: modify
154 delete: objectClass
155 objectClass: OpenLDAPperson
156 -
157 add: objectClass
158 objectClass: testPerson
159 -
160 delete: structuralObjectClass
161 -
162 add: structuralObjectClass
163 structuralObjectClass: testPerson
164
165 EOMODS
166
167 RC=$?
168 if test $RC != 0 ; then
169         echo "ldapmodify failed ($RC)!  IGNORED"
170 #       test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 #       exit $RC
172 fi
173
174 echo "Using ldapsearch to retrieve all the entries..."
175 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
176     'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
177 RC=$?
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 if test $RC != 0 ; then
180         echo "ldapsearch failed ($RC)!"
181         exit $RC
182 fi
183
184 LDIF=$MANAGEOUT
185
186 echo "Filtering ldapsearch results..."
187 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
188 echo "Filtering original ldif used to create database..."
189 . $LDIFFILTER < $LDIF > $LDIFFLT
190 echo "Comparing filter output..."
191 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
192
193 if test $? != 0 ; then
194         echo "comparison failed - manage operations did not complete correctly"
195         exit 1
196 fi
197
198 echo ">>>>> Test succeeded"
199 exit 0