summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tests/test-tdb-features.sh
blob: a78d2d3dd5607ba00fd19dc441c8d6e1a0fdfb94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh

echo "Running tdb feature tests"

rm -f $LDB_URL

checkcount() {
    count=$1
    expression="$2"
    n=`bin/ldbsearch "$expression" | grep ^dn | wc -l`
    if [ $n != $count ]; then
	echo "Got $n but expected $count for $expression"
	$VALGRIND bin/ldbsearch "$expression"
	exit 1
    fi
    echo "OK: $count $expression"
}

echo "Testing case sensitve search"
cat <<EOF | $VALGRIND bin/ldbadd || exit 1
dn: cn=t1,cn=TEST
objectClass: testclass
test: foo
EOF
checkcount 1 '(test=foo)'
checkcount 0 '(test=FOO)'
checkcount 0 '(test=fo*)'

echo "Making case insensitive"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @ATTRIBUTES
changetype: add
add: test
test: CASE_INSENSITIVE
EOF

echo $ldif | $VALGRIND bin/ldbmodify || exit 1
checkcount 1 '(test=foo)'
checkcount 1 '(test=FOO)'
checkcount 0 '(test=fo*)'

echo "adding wildcard"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @ATTRIBUTES
changetype: modify
add: test
test: WILDCARD
EOF
checkcount 1 '(test=foo)'
checkcount 1 '(test=FOO)'
checkcount 1 '(test=fo*)'

echo "adding i"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
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"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @ATTRIBUTES
changetype: modify
add: i
i: INTEGER
EOF
checkcount 1 '(i=0x100)'
checkcount 1 '(i=256)'

echo "adding j"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: cn=t1,cn=TEST
changetype: modify
add: j
j: 0x100
EOF
checkcount 1 '(j=0x100)'
checkcount 0 '(j=256)'

echo "Adding wildcard attribute"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @ATTRIBUTES
changetype: modify
add: *
*: INTEGER
EOF
checkcount 1 '(j=0x100)'
checkcount 1 '(j=256)'

echo "Testing class search"
checkcount 0 '(objectClass=otherclass)'
checkcount 1 '(objectClass=testclass)'

echo "Adding subclass"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @SUBCLASSES
changetype: add
add: otherclass
otherclass: testclass
EOF
checkcount 1 '(objectClass=otherclass)'
checkcount 1 '(objectClass=testclass)'

echo "Adding index"
cat <<EOF | $VALGRIND bin/ldbadd || exit 1
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)'
checkcount 1 '(test=fo*)'

echo "making test case sensitive"
cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
dn: @ATTRIBUTES
changetype: modify
replace: test
test: NONE
EOF
checkcount 1 '(test=foo)'
checkcount 0 '(test=FOO)'
checkcount 0 '(test=fo*)'

rm -f $LDB_URL