libnet: Fix Coverity ID 1634803 Dereference after null check
[samba4-gss.git] / source3 / script / tests / test_valid_users.sh
blob659eb6abaa26564d25e4ed5fa96cb2c601643016
1 #!/bin/sh
3 # Blackbox test for valid users.
6 if [ $# -lt 7 ]; then
7 cat <<EOF
8 Usage: valid_users SERVER SERVER_IP DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT
9 EOF
10 exit 1
13 SERVER=${1}
14 SERVER_IP=${2}
15 DOMAIN=${3}
16 USERNAME=${4}
17 PASSWORD=${5}
18 PREFIX=${6}
19 SMBCLIENT=${7}
20 shift 7
21 SMBCLIENT="$VALGRIND ${SMBCLIENT}"
22 ADDARGS="$*"
24 incdir=$(dirname $0)/../../../testprogs/blackbox
25 . $incdir/subunit.sh
27 failed=0
29 # Test listing a share with valid users succeeds
30 test_valid_users_access()
32 tmpfile=$PREFIX/smbclient.in.$$
33 prompt="foo"
34 cat >$tmpfile <<EOF
36 quit
37 EOF
39 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$1" -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
40 eval echo "$cmd"
41 out=$(eval $cmd)
42 ret=$?
43 rm -f $tmpfile
45 if [ $ret != 0 ]; then
46 echo "$out"
47 echo "failed accessing share with valid users with error $ret"
49 false
50 return
53 echo "$out" | grep "$prompt" >/dev/null 2>&1
55 ret=$?
56 if [ $ret = 0 ]; then
57 # got the correct prompt .. succeed
58 true
59 else
60 echo "$out"
61 echo "failed listing share with valid users"
62 false
66 testit "accessing a valid users share succeeds" \
67 test_valid_users_access valid-users-access ||
68 failed=$(expr $failed + 1)
70 exit $failed