]> git.sur5r.net Git - openldap/blob - tests/scripts/test037-manage
c31f887220a25c7276ec5726d8889b8aff083d1c
[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 -MM -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
62         $TESTOUT 2>&1 << EOMODS
63 version: 1
64
65 # LEADING COMMENT AND WHITE SPACE
66
67 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
68 # update structural object class of entry via objectClass replace
69 changetype: modify
70 replace: objectClass
71 objectClass: testPerson
72
73 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
74 # update structural object class of entry via objectClass modify
75 changetype: modify
76 delete: objectClass
77 objectClass: OpenLDAPperson
78 -
79 add: objectClass
80 objectClass: testPerson
81
82 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
83 # change entryUUID
84 changetype: modify
85 replace: entryUUID
86 entryUUID: B51EE239-C24A-11D9-A541-000D9342AD1E
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 "Using ldapsearch to retrieve all the entries..."
110 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
111             'objectClass=*' > $SEARCHOUT 2>&1
112 RC=$?
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 if test $RC != 0 ; then
115         echo "ldapsearch failed ($RC)!"
116         exit $RC
117 fi
118
119 LDIF=$MODIFYOUTMASTER
120
121 echo "Filtering ldapsearch results..."
122 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
123 echo "Filtering original ldif used to create database..."
124 . $LDIFFILTER < $LDIF > $LDIFFLT
125 echo "Comparing filter output..."
126 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
127
128 if test $? != 0 ; then
129         echo "comparison failed - manage operations did not complete correctly"
130         exit 1
131 fi
132
133 echo ">>>>> Test succeeded"
134 exit 0