waf: Check correctly if gnutls has been compiled with fips mode support
[samba.git] / source4 / setup / tests / blackbox_provision.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: blackbox_provision.sh PREFIX
6 EOF
7 exit 1;
8 fi
9
10 PREFIX="$1"
11 shift 1
12
13 . `dirname $0`/../../../testprogs/blackbox/subunit.sh
14
15 #Prepare an empty smb.conf to ensure it is overwritten
16 rm -rf $PREFIX/simple-default
17 mkdir -p $PREFIX/simple-default/etc
18 touch $PREFIX/simple-default/etc/smb.conf
19 testit "simple-default" $PYTHON $BINDIR/samba-tool domain provision --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-default --use-ntvfs
20 #And try with just whitespace
21 rm -rf $PREFIX/simple-dc
22 mkdir -p $PREFIX/simple-dc/etc
23 echo "  " > $PREFIX/simple-dc/etc/smb.conf
24 testit "simple-dc" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc --use-ntvfs
25 #The rest of these tests are with no smb.conf file present
26
27 rm -rf $PREFIX/simple-dc
28 testit "simple-dc-guids" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --domain-guid=6054d36d-2bfd-44f1-a9cd-32cfbb06480b --ntds-guid=b838f255-c8aa-4fe8-9402-b7d61ca3bd1b --invocationid=6d4cff9a-2bbf-4b4c-98a2-36242ddb0bd6 --targetdir=$PREFIX/simple-dc --use-ntvfs
29 rm -rf $PREFIX/simple-dc-2008r2-schema
30 testit "simple-dc-2008r2-schema" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-dc-2008r2-schema --use-ntvfs --base-schema=2008_R2
31 rm -rf $PREFIX/simple-member
32 testit "simple-member" $PYTHON $BINDIR/samba-tool domain provision --server-role="member" --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-member --use-ntvfs
33 rm -rf $PREFIX/simple-standalone
34 testit "simple-standalone" $PYTHON $BINDIR/samba-tool domain provision --server-role="standalone" --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-standalone --use-ntvfs
35 rm -rf $PREFIX/blank-dc
36 testit "blank-dc" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/blank-dc --blank --use-ntvfs
37
38 reprovision() {
39         $PYTHON $BINDIR/samba-tool domain provision --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/simple-default" --use-ntvfs
40 }
41
42 testit "reprovision" reprovision
43
44 V_2012_R2=69
45 V_2008_R2=47
46
47 check_baseschema() {
48         ldbsearch="ldbsearch"
49         if [ -x "$BINDIR/ldbsearch" ]; then
50             ldbsearch="$BINDIR/ldbsearch"
51         fi
52
53         base=$($ldbsearch -H $PREFIX/$1/private/sam.ldb -s base dn)
54         dom=$(echo "$base" | grep "dn: " | cut -d " " -f 2);
55
56         if [ -z "$dom" ]; then
57                 echo "Unexpected ldbsearch output: $base";
58         fi
59
60         version=$($ldbsearch -H $PREFIX/$1/private/sam.ldb -s base \
61                   "objectVersion" -b "CN=SCHEMA,CN=CONFIGURATION,$dom");
62         version_num=$(echo "$version" | grep "objectVersion: " | cut -d " " -f 2);
63
64         if [ "$version_num" -eq "$2" ]; then
65                 return 0;
66         fi
67
68         echo "Fail: schema version $version_num != $2";
69         return 1;
70 }
71
72 tname="schema version"
73 testit "$tname simple-default" check_baseschema simple-default $V_2012_R2
74 testit "$tname simple-dc" check_baseschema simple-dc $V_2012_R2
75 testit "$tname simple-member" check_baseschema simple-member $V_2012_R2
76 testit "$tname simple-standalone" check_baseschema simple-standalone $V_2012_R2
77 testit "$tname simple-dc-2008r2-schema" check_baseschema simple-dc-2008r2-schema $V_2008_R2
78
79 rm -rf $PREFIX/simple-default
80 rm -rf $PREFIX/simple-dc
81 rm -rf $PREFIX/blank-dc
82 rm -rf $PREFIX/simple-member
83 rm -rf $PREFIX/simple-standalone
84 rm -rf $PREFIX/partitions-only-dc
85
86 exit $failed