test037-manage revision 1.1.1.5
1#! /bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2016 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 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18 19if test $BACKEND = "ldif" ; then 20 echo "LDIF backend does not support relax control, test skipped" 21 exit 0 22fi 23 24mkdir -p $TESTDIR $DBDIR1 25 26echo "Running slapadd to build slapd database..." 27. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1 28$SLAPADD -f $CONF1 -l $LDIFORDERED 29RC=$? 30if test $RC != 0 ; then 31 echo "slapadd failed ($RC)!" 32 exit $RC 33fi 34 35echo "Starting slapd on TCP/IP port $PORT1..." 36$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 37PID=$! 38if test $WAIT != 0 ; then 39 echo PID $PID 40 read foo 41fi 42KILLPIDS="$PID" 43 44sleep 1 45 46echo "Testing slapd Manage operations..." 47for i in 0 1 2 3 4 5; do 48 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ 49 'objectclass=*' > /dev/null 2>&1 50 RC=$? 51 if test $RC = 0 ; then 52 break 53 fi 54 echo "Waiting 5 seconds for slapd to start..." 55 sleep 5 56done 57 58if test $RC != 0 ; then 59 echo "ldapsearch failed ($RC)!" 60 test $KILLSERVERS != no && kill -HUP $KILLPIDS 61 exit $RC 62fi 63 64echo "Testing modify, add, and delete..." 65$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 66 -e \!relax > \ 67 $TESTOUT 2>&1 << EOMODS 68version: 1 69# 70# Working Tests 71# 72 73# 74# ObjectClass tests 75# 76 77dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, 78 dc=com 79# add obsolete auxiliary objectclass 80changetype: modify 81add: objectClass 82objectClass: obsoletePerson 83 84dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, 85 dc=com 86# add obsolete attribute 87changetype: modify 88add: testObsolete 89testObsolete: TRUE 90 91# 92# create/modify timestamp test 93# 94 95dn: ou=Groups,dc=example,dc=com 96# change creatorsName 97changetype: modify 98replace: creatorsName 99creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 100 101dn: cn=ITD Staff,ou=Groups,dc=example,dc=com 102# change modifiersName 103changetype: modify 104replace: modifiersName 105modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 106 107dn: dc=example,dc=com 108# change timestamps 109changetype: modify 110replace: modifyTimestamp 111modifyTimestamp: 19700101000000Z 112- 113replace: createTimestamp 114createTimestamp: 19700101000000Z 115- 116 117dn: cn=All Staff,ou=Groups,dc=example,dc=com 118# change entryUUID 119changetype: modify 120replace: entryUUID 121entryUUID: badbadba-dbad-1029-92f7-badbadbadbad 122 123dn: cn=All Staff,dc=example,dc=com 124changetype: add 125objectClass: groupOfNames 126cn: All Staff 127member: 128creatorsName: cn=Someone 129createTimestamp: 19700101000000Z 130modifiersName: cn=Someone Else 131modifyTimestamp: 19700101000000Z 132entryUUID: badbadef-dbad-1029-92f7-badbadbadbad 133 134# 135# Tests that did not work until ITS#5792 136# 137 138dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, 139 dc=com 140# update structural object class of entry via objectClass replace 141changetype: modify 142replace: objectClass 143objectClass: obsoletePerson 144objectClass: testPerson 145- 146 147dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com 148# update structural object class of entry via objectClass add 149changetype: modify 150add: objectClass 151objectClass: testPerson 152- 153 154dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 155# update structural object class of entry via objectClass delete/add 156changetype: modify 157delete: objectClass 158objectClass: OpenLDAPperson 159- 160add: objectClass 161objectClass: testPerson 162- 163EOMODS 164 165RC=$? 166if test $RC != 0 ; then 167 echo "ldapmodify failed ($RC)!" 168 test $KILLSERVERS != no && kill -HUP $KILLPIDS 169 exit $RC 170fi 171 172echo "Using ldapsearch to retrieve all the entries..." 173$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ 174 'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1 175RC=$? 176if test $RC != 0 ; then 177 test $KILLSERVERS != no && kill -HUP $KILLPIDS 178 echo "ldapsearch failed ($RC)!" 179 exit $RC 180fi 181 182$LDAPSEARCH -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \ 183 'objectClass=*' '*' creatorsName createTimestamp \ 184 modifiersName modifyTimestamp >> $SEARCHOUT 2>&1 185RC=$? 186if test $RC != 0 ; then 187 test $KILLSERVERS != no && kill -HUP $KILLPIDS 188 echo "ldapsearch failed ($RC)!" 189 exit $RC 190fi 191 192$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ 193 '(cn=All Staff)' '*' entryUUID >> $SEARCHOUT 2>&1 194RC=$? 195test $KILLSERVERS != no && kill -HUP $KILLPIDS 196if test $RC != 0 ; then 197 echo "ldapsearch failed ($RC)!" 198 exit $RC 199fi 200 201LDIF=$MANAGEOUT 202 203echo "Filtering ldapsearch results..." 204$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 205echo "Filtering original ldif used to create database..." 206$LDIFFILTER < $LDIF > $LDIFFLT 207echo "Comparing filter output..." 208$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 209 210if test $? != 0 ; then 211 echo "comparison failed - manage operations did not complete correctly" 212 exit 1 213fi 214 215echo ">>>>> Test succeeded" 216 217test $KILLSERVERS != no && wait 218 219exit 0 220