Home | History | Annotate | Line # | Download | only in scripts
test004-modify revision 1.1
      1  1.1  lukem #! /bin/sh
      2  1.1  lukem # $OpenLDAP: pkg/ldap/tests/scripts/test004-modify,v 1.60.2.3 2008/02/11 23:26:51 kurt Exp $
      3  1.1  lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4  1.1  lukem ##
      5  1.1  lukem ## Copyright 1998-2008 The OpenLDAP Foundation.
      6  1.1  lukem ## All rights reserved.
      7  1.1  lukem ##
      8  1.1  lukem ## Redistribution and use in source and binary forms, with or without
      9  1.1  lukem ## modification, are permitted only as authorized by the OpenLDAP
     10  1.1  lukem ## Public License.
     11  1.1  lukem ##
     12  1.1  lukem ## A copy of this license is available in the file LICENSE in the
     13  1.1  lukem ## top-level directory of the distribution or, alternatively, at
     14  1.1  lukem ## <http://www.OpenLDAP.org/license.html>.
     15  1.1  lukem 
     16  1.1  lukem echo "running defines.sh"
     17  1.1  lukem . $SRCDIR/scripts/defines.sh
     18  1.1  lukem 
     19  1.1  lukem mkdir -p $TESTDIR $DBDIR1
     20  1.1  lukem 
     21  1.1  lukem echo "Running slapadd to build slapd database..."
     22  1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
     23  1.1  lukem $SLAPADD -f $CONF1 -l $LDIFORDERED
     24  1.1  lukem RC=$?
     25  1.1  lukem if test $RC != 0 ; then
     26  1.1  lukem 	echo "slapadd failed ($RC)!"
     27  1.1  lukem 	exit $RC
     28  1.1  lukem fi
     29  1.1  lukem 
     30  1.1  lukem echo "Starting slapd on TCP/IP port $PORT1..."
     31  1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     32  1.1  lukem PID=$!
     33  1.1  lukem if test $WAIT != 0 ; then
     34  1.1  lukem     echo PID $PID
     35  1.1  lukem     read foo
     36  1.1  lukem fi
     37  1.1  lukem KILLPIDS="$PID"
     38  1.1  lukem 
     39  1.1  lukem sleep 1
     40  1.1  lukem 
     41  1.1  lukem echo "Testing slapd modify operations..."
     42  1.1  lukem for i in 0 1 2 3 4 5; do
     43  1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     44  1.1  lukem 		'objectclass=*' > /dev/null 2>&1
     45  1.1  lukem 	RC=$?
     46  1.1  lukem 	if test $RC = 0 ; then
     47  1.1  lukem 		break
     48  1.1  lukem 	fi
     49  1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
     50  1.1  lukem 	sleep 5
     51  1.1  lukem done
     52  1.1  lukem 
     53  1.1  lukem if test $RC != 0 ; then
     54  1.1  lukem 	echo "ldapsearch failed ($RC)!"
     55  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     56  1.1  lukem 	exit $RC
     57  1.1  lukem fi
     58  1.1  lukem 
     59  1.1  lukem echo "Testing modify, add, and delete..."
     60  1.1  lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
     61  1.1  lukem 	$TESTOUT 2>&1 << EOMODS
     62  1.1  lukem version: 1
     63  1.1  lukem 
     64  1.1  lukem # LEADING COMMENT AND WHITE SPACE
     65  1.1  lukem 
     66  1.1  lukem dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
     67  1.1  lukem # EMBEDDED COMMENT
     68  1.1  lukem changetype: modify
     69  1.1  lukem add: drink
     70  1.1  lukem drink: Pils
     71  1.1  lukem -
     72  1.1  lukem add: drink
     73  1.1  lukem drink: Orange Juice
     74  1.1  lukem -
     75  1.1  lukem delete: drink
     76  1.1  lukem drink: Pils
     77  1.1  lukem -
     78  1.1  lukem delete: sn
     79  1.1  lukem sn: Jones
     80  1.1  lukem -
     81  1.1  lukem add: sn
     82  1.1  lukem sn: Jones
     83  1.1  lukem 
     84  1.1  lukem dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
     85  1.1  lukem changetype: modify
     86  1.1  lukem # EMBEDDED COMMENT
     87  1.1  lukem  CONTINUED
     88  1.1  lukem replace: description
     89  1.1  lukem description: The replaced multiLineDescription $ Blah Woof.
     90  1.1  lukem -
     91  1.1  lukem replace: drink
     92  1.1  lukem drink: Iced Tea
     93  1.1  lukem drink: Mad Dog 20/20
     94  1.1  lukem 
     95  1.1  lukem dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
     96  1.1  lukem changetype: modify
     97  1.1  lukem delete: uniquemember
     98  1.1  lukem uniquemember: cn=James A Jones 2,ou=Information Technology Division,
     99  1.1  lukem  ou=People,dc=example,dc=com
    100  1.1  lukem uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,
    101  1.1  lukem  ou=People,dc=example,dc=com
    102  1.1  lukem -
    103  1.1  lukem add: uniquemember
    104  1.1  lukem uniquemember: cn=Dorothy Stevens,ou=Alumni Association,
    105  1.1  lukem  ou=People,dc=example,dc=com
    106  1.1  lukem uniquemember: cn=James A Jones 1,ou=Alumni Association,
    107  1.1  lukem  ou=People,dc=example,dc=com
    108  1.1  lukem -
    109  1.1  lukem add: objectClass
    110  1.1  lukem objectClass: OpenLDAPdisplayableObject
    111  1.1  lukem objectClass: pkiUser
    112  1.1  lukem objectClass: userSecurityInformation
    113  1.1  lukem -
    114  1.1  lukem delete: objectClass
    115  1.1  lukem objectClass: userSecurityInformation
    116  1.1  lukem objectClass: pkiUser
    117  1.1  lukem objectClass: OpenLDAPdisplayableObject
    118  1.1  lukem 
    119  1.1  lukem dn: cn=All Staff,ou=Groups,dc=example,dc=com
    120  1.1  lukem changetype: modify
    121  1.1  lukem delete: member
    122  1.1  lukem -
    123  1.1  lukem add: member
    124  1.1  lukem member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
    125  1.1  lukem -
    126  1.1  lukem delete: description
    127  1.1  lukem -
    128  1.1  lukem add: objectClass
    129  1.1  lukem objectClass: OpenLDAPdisplayableObject
    130  1.1  lukem objectClass: pkiUser
    131  1.1  lukem objectClass: userSecurityInformation
    132  1.1  lukem -
    133  1.1  lukem delete: objectClass
    134  1.1  lukem objectClass: OpenLDAPdisplayableObject
    135  1.1  lukem objectClass: pkiUser
    136  1.1  lukem objectClass: userSecurityInformation
    137  1.1  lukem 
    138  1.1  lukem dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
    139  1.1  lukem changetype: add
    140  1.1  lukem objectclass: testPerson
    141  1.1  lukem cn: Gern Jensen
    142  1.1  lukem sn: Jensen
    143  1.1  lukem uid: gjensen
    144  1.1  lukem title: Chief Investigator, ITD
    145  1.1  lukem postaladdress: ITD $ 535 W. William St $ Anytown, MI 48103
    146  1.1  lukem seealso: cn=All Staff,ou=Groups,dc=example,dc=com
    147  1.1  lukem drink: Coffee
    148  1.1  lukem homepostaladdress: 844 Brown St. Apt. 4 $ Anytown, MI 48104
    149  1.1  lukem description: Very odd
    150  1.1  lukem facsimiletelephonenumber: +1 313 555 7557
    151  1.1  lukem telephonenumber: +1 313 555 8343
    152  1.1  lukem mail: gjensen@mailgw.example.com
    153  1.1  lukem homephone: +1 313 555 8844
    154  1.1  lukem testTime: 20050304001801.234Z
    155  1.1  lukem 
    156  1.1  lukem dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example,dc=com
    157  1.1  lukem changetype: delete
    158  1.1  lukem # TRAILING COMMENT AND WHITE SPACE
    159  1.1  lukem 
    160  1.1  lukem dn: ou=People,dc=example,dc=com
    161  1.1  lukem changetype: modify
    162  1.1  lukem increment: uidNumber
    163  1.1  lukem uidNumber: 1
    164  1.1  lukem -
    165  1.1  lukem increment: gidNumber
    166  1.1  lukem gidNumber: -1
    167  1.1  lukem 
    168  1.1  lukem dn: dc=example,dc=com
    169  1.1  lukem changetype: modify
    170  1.1  lukem # EMPTY SEQUENCE OF CHANGE
    171  1.1  lukem 
    172  1.1  lukem EOMODS
    173  1.1  lukem 
    174  1.1  lukem RC=$?
    175  1.1  lukem if test $RC != 0 ; then
    176  1.1  lukem 	echo "ldapmodify failed ($RC)!"
    177  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    178  1.1  lukem 	exit $RC
    179  1.1  lukem fi
    180  1.1  lukem 
    181  1.1  lukem echo "Using ldapmodify to add an empty entry (should fail with protocolError)..."
    182  1.1  lukem $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
    183  1.1  lukem 	 >> $TESTOUT 2>&1 << EOMODS
    184  1.1  lukem dn: cn=Foo Bar,dc=example,dc=com
    185  1.1  lukem changetype: add
    186  1.1  lukem # EMPTY SEQUENCE OF ATTRS
    187  1.1  lukem EOMODS
    188  1.1  lukem 
    189  1.1  lukem RC=$?
    190  1.1  lukem case $RC in
    191  1.1  lukem 2)
    192  1.1  lukem 	echo "	ldapmodify failed ($RC)"
    193  1.1  lukem 	;;
    194  1.1  lukem 0)
    195  1.1  lukem 	echo "	ldapmodify should have failed ($RC)!"
    196  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    197  1.1  lukem 	exit -1
    198  1.1  lukem 	;;
    199  1.1  lukem *)
    200  1.1  lukem 	echo "	ldapmodify failed ($RC)!"
    201  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    202  1.1  lukem 	exit $RC
    203  1.1  lukem 	;;
    204  1.1  lukem esac
    205  1.1  lukem 
    206  1.1  lukem echo "Using ldapsearch to retrieve all the entries..."
    207  1.1  lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    208  1.1  lukem 	    'objectClass=*' > $SEARCHOUT 2>&1
    209  1.1  lukem RC=$?
    210  1.1  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    211  1.1  lukem if test $RC != 0 ; then
    212  1.1  lukem 	echo "ldapsearch failed ($RC)!"
    213  1.1  lukem 	exit $RC
    214  1.1  lukem fi
    215  1.1  lukem 
    216  1.1  lukem LDIF=$MODIFYOUTMASTER
    217  1.1  lukem 
    218  1.1  lukem echo "Filtering ldapsearch results..."
    219  1.1  lukem . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    220  1.1  lukem echo "Filtering original ldif used to create database..."
    221  1.1  lukem . $LDIFFILTER < $LDIF > $LDIFFLT
    222  1.1  lukem echo "Comparing filter output..."
    223  1.1  lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    224  1.1  lukem 
    225  1.1  lukem if test $? != 0 ; then
    226  1.1  lukem 	echo "comparison failed - modify operations did not complete correctly"
    227  1.1  lukem 	exit 1
    228  1.1  lukem fi
    229  1.1  lukem 
    230  1.1  lukem echo ">>>>> Test succeeded"
    231  1.1  lukem 
    232  1.1  lukem test $KILLSERVERS != no && wait
    233  1.1  lukem 
    234  1.1  lukem exit 0
    235