vfs: Fix a typo
[Samba.git] / testprogs / blackbox / test_net_offline.sh
blobb15e77edd95c19f819e40c91cb604a80d1c57c03
1 if [ $# -lt 4 ]; then
2 cat <<EOF
3 Usage: test_net.sh DC_SERVER DC_USERNAME DC_PASSWORD PREFIX_ABS
4 EOF
5 exit 1
6 fi
8 DC_SERVER=$1
9 DC_USERNAME=$2
10 DC_PASSWORD=$3
11 BASEDIR=$4
13 HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10)
15 RUNDIR=$(pwd)
16 cd $BASEDIR
17 WORKDIR=$(mktemp -d -p .)
18 WORKDIR=$(basename $WORKDIR)
19 ODJFILE="$BASEDIR/$WORKDIR/odj_provision.txt"
21 cp -a client/* $WORKDIR/
22 sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
23 sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
24 rm -f $WORKDIR/private/secrets.tdb
25 cd $RUNDIR
27 failed=0
29 net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads"
31 # Load test functions
32 . $(dirname $0)/subunit.sh
34 netbios=$(grep "netbios name" $BASEDIR/$WORKDIR/client.conf | cut -f2 -d= | awk '{$1=$1};1')
36 # 1. Test w/o dcname
38 testit "provision without dcname" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
40 testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
42 testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
44 rm -f $ODJFILE
46 # 2. Test with dcname
48 testit "provision with dcname" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE dcname=$DC_SERVER -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
50 testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
52 testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
54 rm -f $ODJFILE
56 # 3. Test with defpwd
58 testit "provision with dcname and default password" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE dcname=$DC_SERVER defpwd -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
60 testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
62 testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
64 rm -f $ODJFILE
66 rm -rf $BASEDIR/$WORKDIR
68 exit $failed