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