r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / lib / ldb / tests / test-generic.sh
blob14337cc135223920ecf7167b72de17151dbc29c8
1 #!/bin/sh
3 if [ -z "$LDB_SPECIALS" ]; then
4 LDB_SPECIALS=1
5 export LDB_SPECIALS
6 fi
8 echo "LDB_URL: $LDB_URL"
10 echo "Adding base elements"
11 $VALGRIND ldbadd $LDBDIR/tests/test.ldif || exit 1
13 echo "Adding again - should fail"
14 ldbadd $LDBDIR/tests/test.ldif 2> /dev/null && {
15 echo "Should have failed to add again - gave $?"
16 exit 1
19 echo "Modifying elements"
20 $VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1
22 echo "Showing modified record"
23 $VALGRIND ldbsearch '(uid=uham)' || exit 1
25 echo "Rename entry"
26 OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
27 NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
28 $VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1
30 echo "Showing renamed record"
31 $VALGRIND ldbsearch '(uid=uham)' || exit 1
33 echo "Starting ldbtest"
34 $VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1
36 if [ $LDB_SPECIALS = 1 ]; then
37 echo "Adding index"
38 $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1
41 echo "Adding bad attributes - should fail"
42 $VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif && {
43 echo "Should fhave failed - gave $?"
44 exit 1
47 echo "testing indexed search"
48 $VALGRIND ldbsearch '(uid=uham)' || exit 1
49 $VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
50 $VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1
51 $VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1
52 $VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1
53 $VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1
54 $VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1
55 $VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
57 # note that the "((" is treated as an attribute not an expression
58 # this matches the openldap ldapsearch behaviour of looking for a '='
59 # to see if the first argument is an expression or not
60 $VALGRIND ldbsearch '((' uid || exit 1
61 $VALGRIND ldbsearch '(objectclass=)' uid || exit 1
62 $VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
64 echo "Test wildcard match"
65 $VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1
66 $VALGRIND ldbsearch '(cn=test*multi)' || exit 1
67 $VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1
68 $VALGRIND ldbsearch '(cn=*test_multi)' || exit 1
69 $VALGRIND ldbsearch '(cn=test_multi*)' || exit 1
70 $VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1
71 $VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1
73 echo "Starting ldbtest indexed"
74 $VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1
76 echo "Testing one level search"
77 count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l`
78 if [ $count != 3 ]; then
79 echo returned $count records - expected 3
80 exit 1
83 echo "Testing binary file attribute value"
84 mkdir -p tests/tmp
85 cp $LDBDIR/tests/samba4.png tests/tmp/samba4.png
86 $VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1
87 count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l`
88 if [ $count != 1 ]; then
89 echo returned $count records - expected 1
90 exit 1
92 rm -f tests/tmp/samba4.png
94 echo "*TODO* Testing UTF8 upper lower case searches !!"
96 echo "Testing compare"
97 count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l`
98 if [ $count != 2 ]; then
99 echo returned $count records - expected 2
100 echo "this fails on openLdap ..."
103 count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
104 if [ $count != 13 ]; then
105 echo returned $count records - expected 13
106 echo "this fails on opsnLdap ..."
109 checkcount() {
110 count=$1
111 scope=$2
112 basedn=$3
113 expression="$4"
114 n=`bin/ldbsearch -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l`
115 if [ $n != $count ]; then
116 echo "Got $n but expected $count for $expression"
117 bin/ldbsearch "$expression"
118 exit 1
120 echo "OK: $count $expression"
123 checkcount 0 'base' '' '(uid=uham)'
124 checkcount 0 'one' '' '(uid=uham)'
126 checkcount 1 'base' 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
127 checkcount 1 'one' 'ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
128 checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb test)'