summaryrefslogtreecommitdiffstats
path: root/source3/script/tests/test_rpcclient_netsessenum.sh
blob: 1d045431d1eefcdde2db5bb4de1837f4e4587953 (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
#!/bin/sh
#
# Blackbox tests for the rpcclient srvsvc commands
#
# Copyright (C) 2018 Christof Schmitt

if [ $# -lt 6 ]; then
	cat <<EOF
Usage: $0 DOMAIN ADMIN_USER ADMIN_PASSWORD SERVER RPCCLIENT SMBTORTURE3 SHARE
EOF
	exit 1
fi

DOMAIN="$1"
ADMIN_USER="$2"
ADMIN_PASSWORD="$3"
SERVER="$4"
RPCCLIENT="$5"
SMBTORTURE3="$6"
SHARE="$7"

USERPASS="-U$DOMAIN/$ADMIN_USER%$ADMIN_PASSWORD"
RPCCLIENTCMD="$RPCCLIENT $SERVER $USERPASS"

incdir=$(dirname $0)/../../../testprogs/blackbox
. $incdir/subunit.sh

failed=0

#
# Verify initial number of sessions.
#
$RPCCLIENTCMD -c NetSessEnum | grep Received
RC=$?
testit "netsessenum" test $RC = 0 || failed=$(expr $failed + 1)

OUT=$($RPCCLIENTCMD -c NetSessEnum | grep Received)
test "$OUT" = "Received 1 entries."
RC=$?
testit "count1" test $RC -eq 0 || failed=$(expr $failed + 1)

#
# Inject smbd crash
#
$SMBTORTURE3 //"$SERVER"/"$SHARE" "$USERPASS" CLEANUP1

#
# Verify number of sessions after crash
#
OUT=$($RPCCLIENTCMD -c NetSessEnum | grep Received)
test "$OUT" = "Received 1 entries."
RC=$?
testit "count2" test $RC -eq 0 || failed=$(expr $failed + 1)

testok $0 $failed