test051-config-undo revision 1.1.1.10 1 1.1 lukem #! /bin/sh
2 1.1.1.4 tron # $OpenLDAP$
3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 lukem ##
5 1.1.1.10 christos ## Copyright 1998-2024 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 $SLAPPASSWD -g -n >$CONFIGPWF
22 1.1 lukem echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
23 1.1 lukem
24 1.1 lukem echo "Running slapadd to build slapd database..."
25 1.1.1.9 christos . $CONFFILTER $BACKEND < $UNDOCONF > $CONF1
26 1.1 lukem $SLAPADD -f $CONF1 <<EOF
27 1.1 lukem dn: o=undo
28 1.1 lukem objectClass: organization
29 1.1 lukem o: undo
30 1.1 lukem
31 1.1 lukem EOF
32 1.1 lukem RC=$?
33 1.1 lukem if test $RC != 0 ; then
34 1.1 lukem echo "slapadd failed ($RC)!"
35 1.1 lukem exit $RC
36 1.1 lukem fi
37 1.1 lukem
38 1.1 lukem echo "Starting slapd on TCP/IP port $PORT1..."
39 1.1 lukem mkdir $TESTDIR/confdir
40 1.1.1.9 christos $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL > $LOG1 2>&1 &
41 1.1 lukem PID=$!
42 1.1 lukem if test $WAIT != 0 ; then
43 1.1 lukem echo PID $PID
44 1.1 lukem read foo
45 1.1 lukem fi
46 1.1 lukem KILLPIDS="$PID"
47 1.1 lukem
48 1.1 lukem sleep 1
49 1.1 lukem for i in 0 1 2 3 4 5; do
50 1.1.1.9 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
51 1.1 lukem 'objectclass=*' > /dev/null 2>&1
52 1.1 lukem RC=$?
53 1.1 lukem if test $RC = 0 ; then
54 1.1 lukem break
55 1.1 lukem fi
56 1.1 lukem echo "Waiting 5 seconds for slapd to start..."
57 1.1 lukem sleep 5
58 1.1 lukem done
59 1.1 lukem if test $RC != 0 ; then
60 1.1 lukem echo "ldapsearch failed ($RC)!"
61 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 1.1 lukem exit $RC
63 1.1 lukem fi
64 1.1 lukem
65 1.1 lukem echo Dynamically assaulting the schema
66 1.1.1.9 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF \
67 1.1 lukem > $TESTOUT 2>&1 <<EOF
68 1.1 lukem dn: cn={0}core,cn=schema,cn=config
69 1.1 lukem changetype: modify
70 1.1 lukem replace: olcObjectClasses
71 1.1 lukem olcObjectClasses: ( rawr )
72 1.1 lukem -
73 1.1 lukem EOF
74 1.1 lukem RC=$?
75 1.1 lukem if test $RC != 80 ; then
76 1.1 lukem echo "invalid objectclass modify allowed ($RC)"
77 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 1.1.1.10 christos exit 1
79 1.1 lukem fi
80 1.1 lukem
81 1.1.1.9 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF \
82 1.1 lukem > $TESTOUT 2>&1 <<EOF
83 1.1 lukem dn: cn={0}core,cn=schema,cn=config
84 1.1 lukem changetype: modify
85 1.1 lukem replace: olcAttributeTypes
86 1.1 lukem olcAttributeTypes: ( rawr )
87 1.1 lukem -
88 1.1 lukem EOF
89 1.1 lukem RC=$?
90 1.1 lukem if test $RC != 80 ; then
91 1.1 lukem echo "invalid attributeType modify allowed ($RC)"
92 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 1.1.1.10 christos exit 1
94 1.1 lukem fi
95 1.1 lukem
96 1.1 lukem echo Surveying the damage
97 1.1.1.9 christos $LDAPMODIFY -D "cn=manager,o=undo" -w secret -H $URI1 <<EOF
98 1.1 lukem dn: o=foo,o=undo
99 1.1 lukem changetype: add
100 1.1 lukem objectClass: organization
101 1.1 lukem o: foo
102 1.1 lukem
103 1.1 lukem EOF
104 1.1 lukem RC=$?
105 1.1 lukem if test $RC != 0 ; then
106 1.1 lukem echo "schema destroyed by an unsuccessful operation"
107 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 1.1.1.10 christos exit 1
109 1.1 lukem fi
110 1.1 lukem
111 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 1.1 lukem
113 1.1 lukem echo ">>>>> Test succeeded"
114 1.1 lukem
115 1.1 lukem test $KILLSERVERS != no && wait
116 1.1 lukem
117 1.1 lukem exit 0
118