]> git.sur5r.net Git - openldap/blob - tests/scripts/test024-unique
Cleanup
[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 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 << EOTUNIQ1
67 dn: uid=dave,ou=users,o=unique
68 objectClass: inetOrgPerson
69 uid: dave
70 sn: nothere
71 cn: dave
72 businessCategory: otest
73 carLicense: TEST
74 departmentNumber: 42
75 displayName: Dave
76 employeeNumber: 69
77 employeeType: contractor
78 givenName: Dave
79 EOTUNIQ1
80
81 RC=$?
82 if test $RC != 0 ; then
83         echo "ldapadd failed ($RC)!"
84         test $KILLSERVERS != no && kill -HUP $KILLPIDS
85         exit $RC
86 fi
87
88 #echo ----------------------
89 #$LDAPSEARCH -S "" -b "o=unique" -h $LOCALHOST -p $PORT1
90
91 echo "Adding a non-unique record..."
92
93 $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
94          $TESTOUT 2>&1 << EOTUNIQ2
95 dn: uid=bill,ou=users,o=unique
96 objectClass: inetOrgPerson
97 uid: bill
98 sn: johnson
99 cn: bill
100 businessCategory: rtest
101 carLicense: ABC123
102 departmentNumber: 42
103 displayName: Bill
104 employeeNumber: 5150
105 employeeType: contractor
106 givenName: Bill
107 EOTUNIQ2
108
109 RC=$?
110 if test $RC != 19 ; then
111         echo "unique check failed ($RC)!"
112         test $KILLSERVERS != no && kill -HUP $KILLPIDS
113         exit -1
114 fi
115
116
117 #echo ----------------------
118 #$LDAPSEARCH -S "" -b "o=unique" -h $LOCALHOST -p $PORT1
119
120
121
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123
124 echo ">>>>> Test succeeded"
125 exit 0