summaryrefslogtreecommitdiffstats
path: root/source3/script/tests/test_net_usershare.sh
blob: bf6334d1c0af216e8361b3d73f8ebaaf9495b286 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

if [ $# -lt 5 ]; then
	cat <<EOF
Usage: test_net_usershare.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD SMBCLIENT <smbclient arguments>
EOF
	exit 1
fi

SERVER="$1"
SERVER_IP="$2"
USERNAME="$3"
PASSWORD="$4"
smbclient="$5"
shift 5
ADDARGS="$@"

failed=0

samba_bindir="$BINDIR"
samba_net="$samba_bindir/net"
samba_smbcontrol="$samba_bindir/smbcontrol"

samba_share_dir="$LOCAL_PATH"
samba_usershare_dir="$samba_share_dir/usershares"

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

test_smbclient()
{
	name="$1"
	share="$2"
	cmd="$3"
	shift 3
	echo "test: $name"
	$VALGRIND $smbclient $CONFIGURATION //$SERVER/$share -c "$cmd" "$@"
	status=$?
	if [ x$status = x0 ]; then
		echo "success: $name"
	else
		echo "failure: $name"
	fi
	return $status
}

test_net_usershare()
{
	name="$1"
	cmd="$2"
	shift
	shift
	echo "test: $name"
	$VALGRIND $samba_net usershare "$cmd" "$@"
	status=$?
	if [ x$status = x0 ]; then
		echo "success: $name"
	else
		echo "failure: $name"
	fi
	return $status
}

###########################################################
# Check if we can add and delete a usershare
###########################################################

samba_usershare_name="test_usershare_1"
samba_usershare_path="$samba_usershare_dir/$samba_usershare_name"

testit "create usershare dir for $samba_usershare_name" mkdir --mode=0755 --verbose $samba_usershare_path || failed=$(expr $failed + 1)

test_net_usershare "net usershare add $samba_usershare_name" "add" "$samba_usershare_name" "$samba_usershare_path" "$samba_usershare_name"

test_net_usershare "net usershare info $samba_usershare_name" "info" "$samba_usershare_name"

test_smbclient "smbclient to $samba_usershare_name" "$samba_usershare_name" 'ls' -U$USERNAME%$PASSWORD || failed=$(expr $failed + 1)

# CLEANUP
test_net_usershare "net usershare delete $samba_usershare_name" "delete" "$samba_usershare_name"
testit "remove usershare dir for $samba_usershare_name" rm -rf $samba_usershare_path || failed=$(expr $failed + 1)

exit $failed