Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test051-config-undo
blobb87990761e1cb62d91ece3ad1a2fc6886b387bc3
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test051-config-undo,v 1.2.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 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.
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 mkdir -p $TESTDIR $DBDIR1
21 $SLAPPASSWD -g -n >$CONFIGPWF
22 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
24 echo "Running slapadd to build slapd database..."
25 . $CONFFILTER $BACKEND $MONITORDB < $UNDOCONF > $CONF1
26 $SLAPADD -f $CONF1 <<EOF
27 dn: o=undo
28 objectClass: organization
29 o: undo
31 EOF
32 RC=$?
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
35 exit $RC
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 mkdir $TESTDIR/confdir
40 $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 PID=$!
42 if test $WAIT != 0 ; then
43 echo PID $PID
44 read foo
46 KILLPIDS="$PID"
48 sleep 1
49 for i in 0 1 2 3 4 5; do
50 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51 'objectclass=*' > /dev/null 2>&1
52 RC=$?
53 if test $RC = 0 ; then
54 break
56 echo "Waiting 5 seconds for slapd to start..."
57 sleep 5
58 done
59 if test $RC != 0 ; then
60 echo "ldapsearch failed ($RC)!"
61 test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 exit $RC
65 echo Dynamically assaulting the schema
66 $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
67 > $TESTOUT 2>&1 <<EOF
68 dn: cn={0}core,cn=schema,cn=config
69 changetype: modify
70 replace: olcObjectClasses
71 olcObjectClasses: ( rawr )
73 EOF
74 RC=$?
75 if test $RC != 80 ; then
76 echo "invalid objectclass modify allowed ($RC)"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 exit -1
81 $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
82 > $TESTOUT 2>&1 <<EOF
83 dn: cn={0}core,cn=schema,cn=config
84 changetype: modify
85 replace: olcAttributeTypes
86 olcAttributeTypes: ( rawr )
88 EOF
89 RC=$?
90 if test $RC != 80 ; then
91 echo "invalid attributeType modify allowed ($RC)"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 exit -1
96 echo Surveying the damage
97 $LDAPMODIFY -D "cn=manager,o=undo" -w secret -h $LOCALHOST -p $PORT1 <<EOF
98 dn: o=foo,o=undo
99 changetype: add
100 objectClass: organization
101 o: foo
104 RC=$?
105 if test $RC != 0 ; then
106 echo "schema destroyed by an unsuccessful operation"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 exit -1
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo ">>>>> Test succeeded"
115 test $KILLSERVERS != no && wait
117 exit 0