r21017: Actually run tests during test phase rather than when generating the recipe.
[ira/wip.git] / testprogs / blackbox / test_ldb.sh
1 #!/bin/sh
2
3 p=$1
4 shift 1
5 options="$*"
6
7 check() {
8         name="$1"
9         shift
10         cmdline="$*"
11         echo "test: $name"
12         $cmdline
13         status=$?
14         if [ x$status = x0 ]; then
15                 echo "success: $name"
16         else
17                 echo "failure: $name"
18                 failed=`expr $failed + 1`
19         fi
20         return $status
21 }
22
23
24
25 check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
26
27 echo "Getting defaultNamingContext"
28 BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
29 echo "BASEDN is $BASEDN"
30
31 check "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
32
33 check "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
34
35 nentries=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
36 echo "Found $nentries entries"
37 if [ $nentries -lt 10 ]; then
38 echo "Should have found at least 10 entries"
39 failed=`expr $failed + 1`
40 fi
41
42 echo "Check rootDSE for Controls"
43 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
44 if [ $nentries -lt 4 ]; then
45 echo "Should have found at least 4 entries"
46 failed=`expr $failed + 1`
47 fi
48
49 echo "Test Paged Results Control"
50 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
51 if [ $nentries -lt 1 ]; then
52 echo "Paged Results Control test returned 0 items"
53 failed=`expr $failed + 1`
54 fi
55
56 echo "Test Server Sort Control"
57 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
58 if [ $nentries -lt 1 ]; then
59 echo "Server Sort Control test returned 0 items"
60 failed=`expr $failed + 1`
61 fi
62
63 echo "Test Extended DN Control"
64 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
65 if [ $nentries -lt 1 ]; then
66 echo "Extended DN Control test returned 0 items"
67 failed=`expr $failed + 1`
68 fi
69
70 echo "Test Attribute Scope Query Control"
71 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
72 if [ $nentries -lt 1 ]; then
73 echo "Attribute Scope Query test returned 0 items"
74 failed=`expr $failed + 1`
75 fi
76 exit $failed