2005-06-30 03:32:43 +00:00
#!/bin/sh
echo "Running tdb feature tests"
2005-07-02 17:30:03 +00:00
mv $LDB_URL $LDB_URL .2
2005-06-30 03:32:43 +00:00
2016-12-01 12:11:46 +13:00
cat <<EOF | $VALGRIND ldbadd || exit 1
dn: @MODULES
@LIST: rdn_name
EOF
2022-02-19 16:09:04 +01:00
checkcount( )
{
count = $1
expression = " $2 "
n = $( $VALGRIND ldbsearch " $expression " | grep '^dn' | wc -l)
if [ $n != $count ] ; then
echo " Got $n but expected $count for $expression "
$VALGRIND ldbsearch " $expression "
exit 1
fi
echo " OK: $count $expression "
2005-06-30 03:32:43 +00:00
}
2005-07-12 12:04:54 +00:00
echo "Testing case sensitive search"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbadd || exit 1
2005-06-30 03:32:43 +00:00
dn: cn = t1,cn= TEST
2005-07-01 02:17:38 +00:00
objectClass: testclass
2005-06-30 03:32:43 +00:00
test: foo
EOF
checkcount 1 '(test=foo)'
checkcount 0 '(test=FOO)'
2005-07-12 12:04:54 +00:00
checkcount 0 '(test=FO*)'
2016-12-01 12:11:46 +13:00
checkcount 1 '(cn=t1)'
2005-06-30 03:32:43 +00:00
echo "Making case insensitive"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-06-30 03:32:43 +00:00
dn: @ATTRIBUTES
changetype: add
add: test
test: CASE_INSENSITIVE
EOF
2012-01-26 09:42:27 +11:00
echo $ldif | $VALGRIND ldbmodify || exit 1
2005-06-30 03:32:43 +00:00
checkcount 1 '(test=foo)'
checkcount 1 '(test=FOO)'
checkcount 1 '(test=fo*)'
echo "adding i"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-06-30 03:32:43 +00:00
dn: cn = t1,cn= TEST
changetype: modify
add: i
i: 0x100
EOF
checkcount 1 '(i=0x100)'
checkcount 0 '(i=256)'
echo "marking i as INTEGER"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-06-30 03:32:43 +00:00
dn: @ATTRIBUTES
changetype: modify
add: i
i: INTEGER
EOF
checkcount 1 '(i=0x100)'
checkcount 1 '(i=256)'
2005-06-30 03:56:55 +00:00
echo "adding j"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-06-30 03:56:55 +00:00
dn: cn = t1,cn= TEST
changetype: modify
add: j
j: 0x100
EOF
2005-06-30 03:59:02 +00:00
checkcount 1 '(j=0x100)'
checkcount 0 '(j=256)'
2005-06-30 03:56:55 +00:00
echo "Adding wildcard attribute"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-06-30 03:56:55 +00:00
dn: @ATTRIBUTES
changetype: modify
add: *
*: INTEGER
EOF
2005-06-30 03:59:02 +00:00
checkcount 1 '(j=0x100)'
checkcount 1 '(j=256)'
2005-06-30 03:32:43 +00:00
2016-12-01 12:11:46 +13:00
cat <<EOF | $VALGRIND ldbadd || exit 1
dn: num = 1
EOF
echo "Testing search for attribute after change to use wildcard"
checkcount 1 '(num=1)'
2005-07-01 02:17:38 +00:00
echo "Testing class search"
checkcount 0 '(objectClass=otherclass)'
checkcount 1 '(objectClass=testclass)'
2005-07-01 05:20:08 +00:00
echo "Adding index"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbadd || exit 1
2005-07-01 05:20:08 +00:00
dn: @INDEXLIST
@IDXATTR: i
@IDXATTR: test
EOF
checkcount 1 '(i=0x100)'
checkcount 1 '(i=256)'
checkcount 0 '(i=-256)'
checkcount 1 '(test=foo)'
checkcount 1 '(test=FOO)'
2005-07-12 12:04:54 +00:00
checkcount 1 '(test=*f*o)'
2005-07-01 05:20:08 +00:00
echo "making test case sensitive"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2005-07-01 05:20:08 +00:00
dn: @ATTRIBUTES
changetype: modify
replace: test
test: NONE
EOF
checkcount 1 '(test=foo)'
checkcount 0 '(test=FOO)'
2005-07-12 12:04:54 +00:00
checkcount 1 '(test=f*o*)'
2005-07-01 05:20:08 +00:00
2022-02-19 16:09:04 +01:00
checkone( )
{
count = $1
base = " $2 "
expression = " $3 "
n = $( $VALGRIND ldbsearch --scope= one -b " $base " " $expression " | grep '^dn' | wc -l)
if [ $n != $count ] ; then
echo " Got $n but expected $count for $expression "
$VALGRIND ldbsearch --scope= one -b " $base " " $expression "
exit 1
fi
echo " OK: $count $expression "
2006-12-11 15:49:39 +00:00
}
echo "Removing wildcard attribute"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2006-12-11 15:49:39 +00:00
dn: @ATTRIBUTES
changetype: modify
delete: *
*: INTEGER
EOF
echo "Adding one level indexes"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbmodify || exit 1
2006-12-11 15:49:39 +00:00
dn: @INDEXLIST
changetype: modify
add: @IDXONE
@IDXONE: 1
EOF
echo "Testing one level indexed search"
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbadd || exit 1
2006-12-11 15:49:39 +00:00
dn: cn = one,cn= t1,cn= TEST
objectClass: oneclass
cn: one
test: one
EOF
checkone 1 "cn=t1,cn=TEST" '(test=one)'
2012-01-26 09:42:27 +11:00
cat <<EOF | $VALGRIND ldbadd || exit 1
2006-12-11 15:49:39 +00:00
dn: cn = two,cn= t1,cn= TEST
objectClass: oneclass
cn: two
test: one
dn: cn = three,cn= t1,cn= TEST
objectClass: oneclass
cn: three
test: one
2012-12-29 21:48:46 -08:00
dn: cn = four,cn= three,cn= t1,cn= TEST
objectClass: oneclass
cn: four
test: one
2006-12-11 15:49:39 +00:00
EOF
checkone 3 "cn=t1,cn=TEST" '(test=one)'
checkone 1 "cn=t1,cn=TEST" '(cn=two)'