]> git.sur5r.net Git - openldap/blob - tests/scripts/test024-unique
Add missing 'kill -HUP $KILLPIDS' statement before an exit.
[openldap] / tests / scripts / test024-unique
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2004-2005 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
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $UNIQUE = uniqueno; then 
20         echo "Attribute Uniqueness overlay not available, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1
25
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $UNIQUECONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFUNIQUE
29 RC=$?
30 if test $RC != 0 ; then
31         echo "slapadd failed ($RC)!"
32         exit $RC
33 fi
34
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
37 PID=$!
38 if test $WAIT != 0 ; then
39     echo PID $PID
40     read foo
41 fi
42 KILLPIDS="$PID"
43
44 echo "Testing slapd attribute uniqueness operations..."
45 for i in 0 1 2 3 4 5; do
46         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47                 'objectclass=*' > /dev/null 2>&1
48         RC=$?
49         if test $RC = 0 ; then
50                 break
51         fi
52         echo "Waiting 5 seconds for slapd to start..."
53         sleep 5
54 done
55
56 if test $RC != 0 ; then
57         echo "ldapsearch failed ($RC)!"
58         test $KILLSERVERS != no && kill -HUP $KILLPIDS
59         exit $RC
60 fi
61
62 echo "Adding a unique record..."
63
64 #$LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
65 #       $TESTOUT 2>&1 << EOTUNIQ1
66 $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
67         > /dev/null << EOTUNIQ1
68 dn: uid=dave,ou=users,o=unique
69 objectClass: inetOrgPerson
70 uid: dave
71 sn: nothere
72 cn: dave
73 businessCategory: otest
74 carLicense: TEST
75 departmentNumber: 42
76 displayName: Dave
77 employeeNumber: 69
78 employeeType: contractor
79 givenName: Dave
80 EOTUNIQ1
81
82 RC=$?
83 if test $RC != 0 ; then
84         echo "ldapadd failed ($RC)!"
85         test $KILLSERVERS != no && kill -HUP $KILLPIDS
86         exit $RC
87 fi
88
89 #echo ----------------------
90 #$LDAPSEARCH -S "" -b "o=unique" -h $LOCALHOST -p $PORT1
91
92 echo "Adding a non-unique record..."
93
94 $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
95          $TESTOUT 2>&1 << EOTUNIQ2
96 dn: uid=bill,ou=users,o=unique
97 objectClass: inetOrgPerson
98 uid: bill
99 sn: johnson
100 cn: bill
101 businessCategory: rtest
102 carLicense: ABC123
103 departmentNumber: 42
104 displayName: Bill
105 employeeNumber: 5150
106 employeeType: contractor
107 givenName: Bill
108 EOTUNIQ2
109
110 RC=$?
111 if test $RC != 19 ; then
112         echo "unique check failed ($RC)!"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit -1
115 fi
116
117
118 #echo ----------------------
119 #$LDAPSEARCH -S "" -b "o=unique" -h $LOCALHOST -p $PORT1
120
121
122
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124
125 echo ">>>>> Test succeeded"
126 exit 0