]> git.sur5r.net Git - openldap/blob - tests/scripts/test005-modrdn
70392336cfc477ad416116c7c4f3c228a18a8691
[openldap] / tests / scripts / test005-modrdn
1 #! /bin/sh
2
3 if test $# -eq 0 ; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8 if test $# -eq 1 ; then
9         BACKEND=$1; shift
10 fi
11
12 echo "running defines.sh $SRCDIR $BACKEND"
13 . $SRCDIR/scripts/defines.sh
14
15 echo "Cleaning up in $DBDIR..."
16
17 rm -f $DBDIR/[!C]*
18
19 echo "Running ldif2ldbm to build slapd database..."
20 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
21 RC=$?
22 if test $RC != 0 ; then
23         echo "ldif2ldbm failed!"
24         exit $RC
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
29 PID=$!
30 echo "Testing slapd modrdn operations..."
31
32 # Make sure we can search the database
33 for i in 0 1 2 3 4 5; do
34         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
35                 'cn=Manager' > /dev/null 2>&1
36         RC=$?
37         if test $RC = 1 ; then
38                 echo "Waiting 5 seconds for slapd to start..."
39                 sleep 5
40         fi
41 done
42
43 if test $RC != 0 ; then
44         echo "ldapsearch failed!"
45         kill -HUP $PID
46         exit $RC
47 fi
48
49 cat /dev/null > $TESTOUT
50
51
52 # -r used to do remove of old rdn
53
54 echo "Testing modrdn(deleteoldrdn=0)..."
55 $LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
56         /dev/null 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
57
58 RC=$?
59 if test $RC != 0 ; then
60         echo "ldapmodrdn failed!"
61         kill -HUP $PID
62         exit $RC
63 fi
64
65 echo "Testing modrdn(deleteoldrdn=1)..."
66 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
67         /dev/null 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
68
69 RC=$?
70 if test $RC != 0 ; then
71         echo "ldapmodrdn failed!"
72         kill -HUP $PID
73         exit $RC
74 fi
75
76 echo "Using ldapsearch to retrieve all the entries..."
77 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
78             'objectClass=*' > $SEARCHOUT 2>&1
79 RC=$?
80 kill -HUP $PID
81 if test $RC != 0 ; then
82         echo "ldapsearch failed!"
83         exit $RC
84 fi
85
86 LDIF=$MODRDNOUTMASTER
87
88 echo "Filtering ldapsearch results..."
89 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
90 echo "Filtering original ldif used to create database..."
91 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
92 echo "Comparing filter output..."
93 cmp $SEARCHFLT $LDIFFLT
94
95 if test $? != 0 ; then
96         echo "comparison failed - modrdn operations did not complete correctly"
97         exit 1
98 fi
99
100 echo ">>>>> Test succeeded"
101
102
103
104 # echo "modrdn test not yet written"
105
106 exit 0