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