2004-11-15 12:30:28 +00:00
#!/bin/sh
2006-08-22 01:32:29 +00:00
if [ -z " $LDB_SPECIALS " ] ; then
2006-08-24 01:03:42 +00:00
LDB_SPECIALS = 1
export LDB_SPECIALS
2006-08-22 01:32:29 +00:00
fi
2004-10-20 19:28:02 +00:00
echo " LDB_URL: $LDB_URL "
2004-04-03 12:29:21 +00:00
echo "Adding base elements"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbadd $LDBDIR /tests/test.ldif || exit 1
2004-04-03 12:29:21 +00:00
2006-10-14 04:43:51 +00:00
echo "Adding again - should fail"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbadd $LDBDIR /tests/test.ldif 2> /dev/null && {
2006-10-14 04:43:51 +00:00
echo " Should have failed to add again - gave $? "
exit 1
}
2004-04-03 12:29:21 +00:00
echo "Modifying elements"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbmodify $LDBDIR /tests/test-modify.ldif || exit 1
2004-04-03 12:29:21 +00:00
echo "Showing modified record"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
2004-05-05 04:27:29 +00:00
2011-04-06 20:14:54 +02:00
echo "Rename entry with ldbmodify - modrdn"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbmodify $LDBDIR /tests/test-modify-modrdn.ldif || exit 1
2011-04-06 20:14:54 +02:00
echo "Rename entry with ldbrename"
2005-06-22 03:08:06 +00:00
OLDDN = "cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
NEWDN = "cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbrename " $OLDDN " " $NEWDN " || exit 1
2004-10-20 19:28:02 +00:00
echo "Showing renamed record"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
2004-10-20 19:28:02 +00:00
2004-10-20 20:48:31 +00:00
echo "Starting ldbtest"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1
2004-05-05 04:27:29 +00:00
2006-08-22 01:32:29 +00:00
if [ $LDB_SPECIALS = 1 ] ; then
echo "Adding index"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbadd $LDBDIR /tests/test-index.ldif || exit 1
2006-08-22 01:32:29 +00:00
fi
2004-05-05 04:27:29 +00:00
2006-10-14 04:43:51 +00:00
echo "Adding bad attributes - should fail"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbadd $LDBDIR /tests/test-wrong_attributes.ldif && {
2006-10-14 04:43:51 +00:00
echo " Should fhave failed - gave $? "
exit 1
}
2005-05-17 21:43:47 +00:00
2010-04-11 16:55:48 +02:00
echo "Testing indexed search"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
$VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1
$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1
$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1
$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1
$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1
$VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
2005-06-22 04:01:27 +00:00
2011-07-28 15:56:15 +10:00
echo "Testing invalid search expression"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '(&(uid=uham)(title=foo\blah))' uid && exit 1
2011-07-28 15:56:15 +10:00
2005-06-22 04:01:27 +00:00
# note that the "((" is treated as an attribute not an expression
# this matches the openldap ldapsearch behaviour of looking for a '='
# to see if the first argument is an expression or not
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '((' uid || exit 1
$VALGRIND ldbsearch '(objectclass=)' uid || exit 1
$VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
2005-01-02 07:49:29 +00:00
2005-07-12 12:04:54 +00:00
echo "Test wildcard match"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbadd $LDBDIR /tests/test-wildcard.ldif || exit 1
$VALGRIND ldbsearch '(cn=test*multi)' || exit 1
$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1
$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1
$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1
$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1
$VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1
2005-07-12 12:04:54 +00:00
2004-10-20 20:48:31 +00:00
echo "Starting ldbtest indexed"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1
2004-09-23 02:15:10 +00:00
echo "Testing one level search"
2012-01-26 09:42:27 +11:00
count = ` $VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none | grep '^dn' | wc -l`
2005-07-01 08:18:48 +00:00
if [ $count != 3 ] ; then
2004-09-23 02:15:10 +00:00
echo returned $count records - expected 3
exit 1
fi
2005-06-21 11:22:05 +00:00
2006-02-28 04:36:29 +00:00
echo "Testing binary file attribute value"
2012-01-26 09:42:27 +11:00
$VALGRIND ldbmodify $LDBDIR /tests/photo.ldif || exit 1
count = ` $VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l`
2006-09-14 18:50:12 +00:00
if [ $count != 1 ] ; then
echo returned $count records - expected 1
exit 1
fi
2006-02-28 04:36:29 +00:00
echo "*TODO* Testing UTF8 upper lower case searches !!"
2005-07-19 09:09:00 +00:00
echo "Testing compare"
2012-01-26 09:42:27 +11:00
count = ` $VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l`
2005-07-19 09:09:00 +00:00
if [ $count != 2 ] ; then
echo returned $count records - expected 2
2006-10-14 04:43:51 +00:00
echo "this fails on openLdap ..."
2005-07-19 09:09:00 +00:00
fi
2012-01-26 09:42:27 +11:00
count = ` $VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
2005-07-19 09:09:00 +00:00
if [ $count != 13 ] ; then
echo returned $count records - expected 13
2008-09-12 13:26:45 -04:00
echo "this fails on openLdap ..."
2005-07-19 09:09:00 +00:00
fi
2005-09-15 23:10:07 +00:00
checkcount( ) {
count = $1
scope = $2
basedn = $3
expression = " $4 "
2012-01-26 09:42:27 +11:00
n = ` $VALGRIND ldbsearch -s " $scope " -b " $basedn " " $expression " | grep '^dn' | wc -l`
2005-09-15 23:10:07 +00:00
if [ $n != $count ] ; then
echo " Got $n but expected $count for $expression "
bin/ldbsearch " $expression "
exit 1
fi
echo " OK: $count $expression "
}
checkcount 0 'base' '' '(uid=uham)'
checkcount 0 'one' '' '(uid=uham)'
checkcount 1 'base' 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
checkcount 1 'one' 'ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
2006-01-10 14:27:48 +00:00
checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb test)'