source: vendor/current/lib/ldb/tests/test-generic.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 5.4 KB
Line 
1#!/bin/sh
2
3if [ -z "$LDB_SPECIALS" ]; then
4 LDB_SPECIALS=1
5 export LDB_SPECIALS
6fi
7
8echo "LDB_URL: $LDB_URL"
9
10echo "Adding base elements"
11$VALGRIND ldbadd $LDBDIR/tests/test.ldif || exit 1
12
13echo "Adding again - should fail"
14$VALGRIND ldbadd $LDBDIR/tests/test.ldif 2> /dev/null && {
15 echo "Should have failed to add again - gave $?"
16 exit 1
17}
18
19echo "Adding LDIF with one already-existing user again - should fail"
20$VALGRIND ldbadd $LDBDIR/tests/test-dup.ldif 2> /dev/null && {
21 echo "Should have failed to add again - gave $?"
22 exit 1
23}
24
25echo "Adding again - should succeed (as previous failed)"
26$VALGRIND ldbadd $LDBDIR/tests/test-dup-2.ldif || exit 1
27
28echo "Modifying elements"
29$VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1
30
31echo "Modify LDIF with one un-met constraint - should fail"
32$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet.ldif 2> /dev/null && {
33 echo "Should have failed to modify - gave $?"
34 exit 1
35}
36
37echo "Modify LDIF with after failure of un-met constraint - should also fail"
38$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet-2.ldif 2> /dev/null && {
39 echo "Should have failed to modify - gave $?"
40 exit 1
41}
42
43echo "Showing modified record"
44$VALGRIND ldbsearch '(uid=uham)' || exit 1
45
46echo "Rename entry with ldbmodify - modrdn"
47$VALGRIND ldbmodify $LDBDIR/tests/test-modify-modrdn.ldif || exit 1
48
49echo "Rename entry with ldbrename"
50OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
51NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
52$VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1
53
54echo "Showing renamed record"
55$VALGRIND ldbsearch '(uid=uham)' || exit 1
56
57echo "Starting ldbtest"
58$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1
59
60if [ $LDB_SPECIALS = 1 ]; then
61 echo "Adding index"
62 $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1
63fi
64
65echo "Adding bad attributes - should fail"
66$VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif && {
67 echo "Should fhave failed - gave $?"
68 exit 1
69}
70
71echo "Testing indexed search"
72$VALGRIND ldbsearch '(uid=uham)' || exit 1
73$VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
74$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1
75$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1
76$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1
77$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1
78$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1
79$VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
80
81echo "Testing invalid search expression"
82$VALGRIND ldbsearch '(&(uid=uham)(title=foo\blah))' uid && exit 1
83
84# note that the "((" is treated as an attribute not an expression
85# this matches the openldap ldapsearch behaviour of looking for a '='
86# to see if the first argument is an expression or not
87$VALGRIND ldbsearch '((' uid || exit 1
88$VALGRIND ldbsearch '(objectclass=)' uid || exit 1
89$VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
90
91echo "Test wildcard match"
92$VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1
93$VALGRIND ldbsearch '(cn=test*multi)' || exit 1
94$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1
95$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1
96$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1
97$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1
98$VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1
99
100echo "Starting ldbtest indexed"
101$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1
102
103echo "Testing one level search"
104count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l`
105if [ $count != 3 ]; then
106 echo returned $count records - expected 3
107 exit 1
108fi
109
110echo "Testing binary file attribute value"
111$VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1
112count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l`
113if [ $count != 1 ]; then
114 echo returned $count records - expected 1
115 exit 1
116fi
117
118echo "*TODO* Testing UTF8 upper lower case searches !!"
119
120echo "Testing compare"
121count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l`
122if [ $count != 2 ]; then
123 echo returned $count records - expected 2
124 echo "this fails on openLdap ..."
125fi
126$VALGRIND ldbsearch '(cn>t)' cn && exit 1 # strictly greater should not work
127
128count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
129if [ $count != 13 ]; then
130 echo returned $count records - expected 13
131 echo "this fails on openLdap ..."
132fi
133$VALGRIND ldbsearch '(cn<t)' cn && exit 1 # strictly less should not work
134
135checkcount() {
136 count=$1
137 scope=$2
138 basedn=$3
139 expression="$4"
140 n=`$VALGRIND ldbsearch -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l`
141 if [ $n != $count ]; then
142 echo "Got $n but expected $count for $expression"
143 bin/ldbsearch "$expression"
144 exit 1
145 fi
146 echo "OK: $count $expression"
147}
148
149checkcount 0 'base' '' '(uid=uham)'
150checkcount 0 'one' '' '(uid=uham)'
151
152checkcount 1 'base' 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
153checkcount 1 'one' 'ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
154checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb test)'
Note: See TracBrowser for help on using the repository browser.