2004-11-15 15:30:28 +03:00
#!/bin/sh
2006-08-22 05:32:29 +04:00
if [ -z " $LDB_SPECIALS " ] ; then
2006-08-24 05:03:42 +04:00
LDB_SPECIALS = 1
export LDB_SPECIALS
2006-08-22 05:32:29 +04:00
fi
2004-10-20 23:28:02 +04:00
echo " LDB_URL: $LDB_URL "
2004-04-03 16:29:21 +04:00
echo "Adding base elements"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbadd $LDBDIR /tests/test.ldif || exit 1
2004-04-03 16:29:21 +04:00
2006-10-14 08:43:51 +04:00
echo "Adding again - should fail"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbadd $LDBDIR /tests/test.ldif 2> /dev/null && {
2006-10-14 08:43:51 +04:00
echo " Should have failed to add again - gave $? "
exit 1
}
2012-04-04 09:17:32 +04:00
echo "Adding LDIF with one already-existing user again - should fail"
$VALGRIND ldbadd $LDBDIR /tests/test-dup.ldif 2> /dev/null && {
echo " Should have failed to add again - gave $? "
exit 1
}
echo "Adding again - should succeed (as previous failed)"
$VALGRIND ldbadd $LDBDIR /tests/test-dup-2.ldif || exit 1
2004-04-03 16:29:21 +04:00
echo "Modifying elements"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbmodify $LDBDIR /tests/test-modify.ldif || exit 1
2004-04-03 16:29:21 +04:00
2012-04-04 09:17:32 +04:00
echo "Modify LDIF with one un-met constraint - should fail"
$VALGRIND ldbadd $LDBDIR /tests/test-modify-unmet.ldif 2> /dev/null && {
echo " Should have failed to modify - gave $? "
exit 1
}
echo "Modify LDIF with after failure of un-met constraint - should also fail"
$VALGRIND ldbadd $LDBDIR /tests/test-modify-unmet-2.ldif 2> /dev/null && {
echo " Should have failed to modify - gave $? "
exit 1
}
2004-04-03 16:29:21 +04:00
echo "Showing modified record"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
2004-05-05 08:27:29 +04:00
2011-04-06 22:14:54 +04:00
echo "Rename entry with ldbmodify - modrdn"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbmodify $LDBDIR /tests/test-modify-modrdn.ldif || exit 1
2011-04-06 22:14:54 +04:00
echo "Rename entry with ldbrename"
2005-06-22 07:08:06 +04: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 02:42:27 +04:00
$VALGRIND ldbrename " $OLDDN " " $NEWDN " || exit 1
2004-10-20 23:28:02 +04:00
echo "Showing renamed record"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
2004-10-20 23:28:02 +04:00
2004-10-21 00:48:31 +04:00
echo "Starting ldbtest"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1
2004-05-05 08:27:29 +04:00
2006-08-22 05:32:29 +04:00
if [ $LDB_SPECIALS = 1 ] ; then
echo "Adding index"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbadd $LDBDIR /tests/test-index.ldif || exit 1
2006-08-22 05:32:29 +04:00
fi
2004-05-05 08:27:29 +04:00
2006-10-14 08:43:51 +04:00
echo "Adding bad attributes - should fail"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbadd $LDBDIR /tests/test-wrong_attributes.ldif && {
2006-10-14 08:43:51 +04:00
echo " Should fhave failed - gave $? "
exit 1
}
2005-05-18 01:43:47 +04:00
2010-04-11 18:55:48 +04:00
echo "Testing indexed search"
2012-01-26 02:42:27 +04: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 08:01:27 +04:00
2011-07-28 09:56:15 +04:00
echo "Testing invalid search expression"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbsearch '(&(uid=uham)(title=foo\blah))' uid && exit 1
2011-07-28 09:56:15 +04:00
2005-06-22 08:01:27 +04: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 02:42:27 +04: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 10:49:29 +03:00
2005-07-12 16:04:54 +04:00
echo "Test wildcard match"
2012-01-26 02:42:27 +04: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 16:04:54 +04:00
2004-10-21 00:48:31 +04:00
echo "Starting ldbtest indexed"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1
2004-09-23 06:15:10 +04:00
echo "Testing one level search"
2012-01-26 02:42:27 +04:00
count = ` $VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none | grep '^dn' | wc -l`
2005-07-01 12:18:48 +04:00
if [ $count != 3 ] ; then
2004-09-23 06:15:10 +04:00
echo returned $count records - expected 3
exit 1
fi
2005-06-21 15:22:05 +04:00
2006-02-28 07:36:29 +03:00
echo "Testing binary file attribute value"
2012-01-26 02:42:27 +04:00
$VALGRIND ldbmodify $LDBDIR /tests/photo.ldif || exit 1
count = ` $VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l`
2006-09-14 22:50:12 +04:00
if [ $count != 1 ] ; then
echo returned $count records - expected 1
exit 1
fi
2006-02-28 07:36:29 +03:00
echo "*TODO* Testing UTF8 upper lower case searches !!"
2005-07-19 13:09:00 +04:00
echo "Testing compare"
2012-01-26 02:42:27 +04:00
count = ` $VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l`
2012-09-04 20:27:48 +04:00
if [ $count != 1 ] ; then
# only "cn: test_multi_test_multi_test_multi" (comes after "t")
# upper-cased words come before "t" - hence excluded
echo returned $count records - expected 1
exit 1
2005-07-19 13:09:00 +04:00
fi
2012-05-10 12:11:51 +04:00
$VALGRIND ldbsearch '(cn>t)' cn && exit 1 # strictly greater should not work
2005-07-19 13:09:00 +04:00
2012-01-26 02:42:27 +04:00
count = ` $VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
2012-09-04 20:27:48 +04:00
if [ $count != 18 ] ; then
# everything except "cn: test_multi_test_multi_test_multi" (comes after "t")
# upper-cased letters come before "t" - hence included
echo returned $count records - expected 18
exit 1
2005-07-19 13:09:00 +04:00
fi
2012-05-10 12:11:51 +04:00
$VALGRIND ldbsearch '(cn<t)' cn && exit 1 # strictly less should not work
2005-07-19 13:09:00 +04:00
2005-09-16 03:10:07 +04:00
checkcount( ) {
count = $1
scope = $2
basedn = $3
expression = " $4 "
2012-01-26 02:42:27 +04:00
n = ` $VALGRIND ldbsearch -s " $scope " -b " $basedn " " $expression " | grep '^dn' | wc -l`
2005-09-16 03:10:07 +04:00
if [ $n != $count ] ; then
echo " Got $n but expected $count for $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 17:27:48 +03:00
checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb test)'