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