]> git.sur5r.net Git - openldap/blob - tests/scripts/test037-manage
0267c91b6b6acfa2e7592952d9b79c789b61cacf
[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 "skipping test (not yet implemented)"
17 exit 0
18
19 echo "running defines.sh"
20 . $SRCDIR/scripts/defines.sh
21
22 mkdir -p $TESTDIR $DBDIR1
23
24 echo "Running slapadd to build slapd database..."
25 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
26 $SLAPADD -f $CONF1 -l $LDIFORDERED
27 RC=$?
28 if test $RC != 0 ; then
29         echo "slapadd failed ($RC)!"
30         exit $RC
31 fi
32
33 echo "Starting slapd on TCP/IP port $PORT1..."
34 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 PID=$!
36 if test $WAIT != 0 ; then
37     echo PID $PID
38     read foo
39 fi
40 KILLPIDS="$PID"
41
42 echo "Testing slapd Manage operations..."
43 for i in 0 1 2 3 4 5; do
44         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
45                 'objectclass=*' > /dev/null 2>&1
46         RC=$?
47         if test $RC = 0 ; then
48                 break
49         fi
50         echo "Waiting 5 seconds for slapd to start..."
51         sleep 5
52 done
53
54 if test $RC != 0 ; then
55         echo "ldapsearch failed ($RC)!"
56         test $KILLSERVERS != no && kill -HUP $KILLPIDS
57         exit $RC
58 fi
59
60 echo "Testing modify, add, and delete..."
61 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
62         -e \!ManageDIT > \
63         $TESTOUT 2>&1 << EOMODS
64 version: 1
65
66 # LEADING COMMENT AND WHITE SPACE
67
68 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
69 # update structural object class of entry via objectClass replace
70 changetype: modify
71 replace: objectClass
72 objectClass: testPerson
73 -
74 replace: objectClass
75 objectClass: structuralObjectClass
76
77 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
78 # update structural object class of entry via objectClass modify
79 changetype: modify
80 delete: objectClass
81 objectClass: OpenLDAPperson
82 -
83 add: objectClass
84 objectClass: testPerson
85 -
86 delete: structuralObjectClass
87 -
88 add: objectClass
89 objectClass: testPerson
90
91 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
92 # change entryUUID
93 changetype: modify
94 replace: entryUUID
95 entryUUID: B51EE239-C24A-11D9-A541-000D9342AD1E
96
97 dn: ou=Groups,dc=example,dc=com
98 # change creatorsName
99 changetype: modify
100 replace: creatorsName
101 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
102
103 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
104 # change modifiersName
105 changetype: modify
106 replace: modifiersName
107 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
108
109 EOMODS
110
111 RC=$?
112 if test $RC != 0 ; then
113         echo "ldapmodify failed ($RC)!"
114         test $KILLSERVERS != no && kill -HUP $KILLPIDS
115         exit $RC
116 fi
117
118 echo "Using ldapsearch to retrieve all the entries..."
119 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
120             'objectClass=*' > $SEARCHOUT 2>&1
121 RC=$?
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 if test $RC != 0 ; then
124         echo "ldapsearch failed ($RC)!"
125         exit $RC
126 fi
127
128 LDIF=$MODIFYOUTMASTER
129
130 echo "Filtering ldapsearch results..."
131 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
132 echo "Filtering original ldif used to create database..."
133 . $LDIFFILTER < $LDIF > $LDIFFLT
134 echo "Comparing filter output..."
135 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
136
137 if test $? != 0 ; then
138         echo "comparison failed - manage operations did not complete correctly"
139         exit 1
140 fi
141
142 echo ">>>>> Test succeeded"
143 exit 0