]> git.sur5r.net Git - openldap/blob - tests/scripts/test037-manage
9ad332351870c16dbe60fa7e5831377bbc0ed29c
[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 case `$LDAPSEARCH -s base -b "" -h $LOCALHOST -p $PORT1 -A \
59         '(supportedControl:objectIdentifierMatch:=1.3.6.1.4.1.4203.666.5.12)' \
60         supportedControl | grep supportedControl` in
61 "supportedControl:")
62         ;;
63 *)
64         echo "The \"manageDIT\" control appears to be unsupported; test disabled"
65         test $KILLSERVERS != no && kill -HUP $KILLPIDS
66         exit 0
67         ;;
68 esac
69
70 echo "Testing modify, add, and delete..."
71 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
72         -e \!manageDIT > \
73         $TESTOUT 2>&1 << EOMODS
74 version: 1
75 #
76 # Working Tests
77 #
78
79 #
80 # ObjectClass tests
81 #
82
83 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
84  dc=com
85 # add obsolete auxiliary objectclass
86 changetype: modify
87 add: objectClass
88 objectClass: obsoletePerson
89
90 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
91  dc=com
92 # add obsolete attribute
93 changetype: modify
94 add: testObsolete
95 testObsolete: TRUE
96
97 #
98 # create/modify timestamp test
99 #
100
101 dn: ou=Groups,dc=example,dc=com
102 # change creatorsName
103 changetype: modify
104 replace: creatorsName
105 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
106
107 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
108 # change modifiersName
109 changetype: modify
110 replace: modifiersName
111 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
112
113 EOMODS
114
115 RC=$?
116 if test $RC != 0 ; then
117         echo "ldapmodify failed ($RC)!"
118         test $KILLSERVERS != no && kill -HUP $KILLPIDS
119         exit $RC
120 fi
121
122 echo "Testing modify, add, and delete..."
123 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
124         -e \!manageDIT > \
125         $TESTOUT 2>&1 << EOMODS
126 version: 1
127 #
128 # Non-working tests
129 #
130
131 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
132  dc=com
133 # update structural object class of entry via objectClass replace
134 changetype: modify
135 replace: objectClass
136 objectClass: obsoletePerson
137 -
138 replace: structuralObjectClass
139 structuralObjectClass: testPerson
140
141 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
142 # update structural object class of entry via objectClass add
143 changetype: modify
144 add: objectClass
145 objectClass: testPerson
146 -
147 replace: structuralObjectClass
148 structuralObjectClass: testPerson
149
150 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
151 # update structural object class of entry via objectClass delete/add
152 changetype: modify
153 delete: objectClass
154 objectClass: OpenLDAPperson
155 -
156 add: objectClass
157 objectClass: testPerson
158 -
159 delete: structuralObjectClass
160 -
161 add: structuralObjectClass
162 structuralObjectClass: testPerson
163
164 EOMODS
165
166 RC=$?
167 if test $RC != 0 ; then
168         echo "ldapmodify failed ($RC)!  IGNORED"
169 #       test $KILLSERVERS != no && kill -HUP $KILLPIDS
170 #       exit $RC
171 fi
172
173 echo "Using ldapsearch to retrieve all the entries..."
174 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
175     'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
176 RC=$?
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 if test $RC != 0 ; then
179         echo "ldapsearch failed ($RC)!"
180         exit $RC
181 fi
182
183 LDIF=$MANAGEOUT
184
185 echo "Filtering ldapsearch results..."
186 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
187 echo "Filtering original ldif used to create database..."
188 . $LDIFFILTER < $LDIF > $LDIFFLT
189 echo "Comparing filter output..."
190 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
191
192 if test $? != 0 ; then
193         echo "comparison failed - manage operations did not complete correctly"
194         exit 1
195 fi
196
197 echo ">>>>> Test succeeded"
198 exit 0