2004-11-15 12:30:28 +00:00
#!/bin/sh
2006-08-22 01:32:29 +00:00
if [ -z " $LDB_SPECIALS " ] ; then
2022-02-19 16:09:04 +01: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"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbadd $LDBDIR /tests/test.ldif 2>/dev/null && {
echo " Should have failed to add again - gave $? "
exit 1
2006-10-14 04:43:51 +00:00
}
2012-04-04 15:17:32 +10:00
echo "Adding LDIF with one already-existing user again - should fail"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbadd $LDBDIR /tests/test-dup.ldif 2>/dev/null && {
echo " Should have failed to add again - gave $? "
exit 1
2012-04-04 15:17:32 +10:00
}
echo "Adding again - should succeed (as previous failed)"
$VALGRIND ldbadd $LDBDIR /tests/test-dup-2.ldif || 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
2012-04-04 15:17:32 +10:00
echo "Modify LDIF with one un-met constraint - should fail"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbadd $LDBDIR /tests/test-modify-unmet.ldif 2>/dev/null && {
echo " Should have failed to modify - gave $? "
exit 1
2012-04-04 15:17:32 +10:00
}
echo "Modify LDIF with after failure of un-met constraint - should also fail"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbadd $LDBDIR /tests/test-modify-unmet-2.ldif 2>/dev/null && {
echo " Should have failed to modify - gave $? "
exit 1
2012-04-04 15:17:32 +10:00
}
2004-04-03 12:29:21 +00:00
echo "Showing modified record"
2022-02-19 16:09:04 +01: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"
2022-02-19 16:09:04 +01: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"
2022-02-19 16:09:04 +01: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
2022-02-19 16:09:04 +01:00
echo "Adding index"
$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 && {
2022-02-19 16:09:04 +01:00
echo " Should fhave failed - gave $? "
exit 1
2006-10-14 04:43:51 +00:00
}
2005-05-17 21:43:47 +00:00
2010-04-11 16:55:48 +02:00
echo "Testing indexed search"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbsearch '(uid=uham)' || exit 1
2012-01-26 09:42:27 +11:00
$VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
2022-02-19 16:09:04 +01:00
$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
2012-01-26 09:42:27 +11:00
$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
2020-12-17 12:25:15 +01:00
$VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' --scope= base "" sn || exit 1
2005-01-02 07:49:29 +00:00
2005-07-12 12:04:54 +00:00
echo "Test wildcard match"
2022-02-19 16:09:04 +01: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
2012-01-26 09:42:27 +11:00
$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"
2022-02-19 16:09:04 +01:00
$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1
2004-09-23 02:15:10 +00:00
echo "Testing one level search"
2022-02-19 16:09:04 +01:00
count = $( $VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' --scope= one 'objectclass=*' none | grep '^dn' | wc -l)
2005-07-01 08:18:48 +00:00
if [ $count != 3 ] ; then
2022-02-19 16:09:04 +01:00
echo returned $count records - expected 3
exit 1
2004-09-23 02:15:10 +00:00
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
2022-02-19 16:09:04 +01:00
count = $( $VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l)
2006-09-14 18:50:12 +00:00
if [ $count != 1 ] ; then
2022-02-19 16:09:04 +01:00
echo returned $count records - expected 1
exit 1
2006-09-14 18:50:12 +00:00
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"
2022-02-19 16:09:04 +01:00
count = $( $VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l)
2012-09-04 18:27:48 +02:00
if [ $count != 1 ] ; then
2022-02-19 16:09:04 +01:00
# 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 09:09:00 +00:00
fi
2012-05-10 10:11:51 +02:00
$VALGRIND ldbsearch '(cn>t)' cn && exit 1 # strictly greater should not work
2005-07-19 09:09:00 +00:00
2022-02-19 16:09:04 +01:00
count = $( $VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l)
2012-09-04 18:27:48 +02:00
if [ $count != 18 ] ; then
2022-02-19 16:09:04 +01:00
# 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 09:09:00 +00:00
fi
2012-05-10 10:11:51 +02:00
$VALGRIND ldbsearch '(cn<t)' cn && exit 1 # strictly less should not work
2005-07-19 09:09:00 +00:00
2022-02-19 16:09:04 +01:00
checkcount( )
{
count = $1
scope = $2
basedn = $3
expression = " $4 "
n = $( $VALGRIND ldbsearch --scope= " $scope " -b " $basedn " " $expression " | grep '^dn' | wc -l)
if [ $n != $count ] ; then
echo " Got $n but expected $count for $expression "
exit 1
fi
echo " OK: $count $expression "
2005-09-15 23:10:07 +00:00
}
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)'