summaryrefslogtreecommitdiff
path: root/nsswitch/tests/test_wbinfo_user_info.sh
blob: 2803ac1408bea42a577e7bd7e38a412f96fe4dee (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
# Blackbox test for wbinfo lookup for account name and upn
# Copyright (c) 2018 Andreas Schneider <asn@samba.org>

if [ $# -lt 5 ]; then
cat <<EOF
Usage: $(basename $0) DOMAIN REALM USERNAME1 UPN_NAME1 USERNAME2 UPN_NAME2
EOF
exit 1;
fi

DOMAIN=$1
REALM=$2
USERNAME1=$3
UPN_NAME1=$4
USERNAME2=$5
UPN_NAME2=$6
shift 6

failed=0

samba_bindir="$BINDIR"
wbinfo_tool="$VALGRIND $samba_bindir/wbinfo"

UPN1="$UPN_NAME1@$REALM"
UPN2="$UPN_NAME2@$REALM"

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

test_user_info()
{
	local cmd out ret user domain upn userinfo

	domain="$1"
	user="$2"
	upn="$3"

	if [ $# -lt 3 ]; then
		userinfo="$domain/$user"
	else
		userinfo="$upn"
	fi

	cmd='$wbinfo_tool --user-info $userinfo'
	eval echo "$cmd"
	out=$(eval $cmd)
	ret=$?
	if [ $ret -ne 0 ]; then
		echo "failed to lookup $userinfo"
		echo "$out"
		return 1
	fi

	echo "$out" | grep "$domain/$user:.*:.*:.*::/home/$domain/Domain Users/$user"
	ret=$?
	if [ $ret != 0 ]; then
		echo "failed to lookup $userinfo"
		echo "$out"
		return 1
	fi

	return 0
}

testit "name_to_sid.domain.$USERNAME1" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME1 || failed=$(expr $failed + 1)
testit "name_to_sid.upn.$UPN_NAME1" $wbinfo_tool --name-to-sid $UPN1 || failed=$(expr $failed + 1)

testit "user_info.domain.$USERNAME1" test_user_info $DOMAIN $USERNAME1 || failed=$(expr $failed + 1)
testit "user_info.upn.$UPN_NAME1" test_user_info $DOMAIN $USERNAME1 $UPN1 || failed=$(expr $failed + 1)

testit "name_to_sid.domain.$USERNAME2" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME2 || failed=$(expr $failed + 1)
testit "name_to_sid.upn.$UPN_NAME2" $wbinfo_tool --name-to-sid $UPN2 || failed=$(expr $failed + 1)

testit "user_info.domain.$USERNAME2" test_user_info $DOMAIN $USERNAME2 || failed=$(expr $failed + 1)
testit "user_info.upn.$UPN_NAME2" test_user_info $DOMAIN $USERNAME2 $UPN2 || failed=$(expr $failed + 1)

USERNAME3="testdenied"
UPN_NAME3="testdenied_upn"
UPN3="$UPN_NAME3@${REALM}.upn"
testit "name_to_sid.upn.$UPN_NAME3" $wbinfo_tool --name-to-sid $UPN3 || failed=$(expr $failed + 1)
testit "user_info.upn.$UPN_NAME3" test_user_info $DOMAIN $USERNAME3 $UPN3 || failed=$(expr $failed + 1)

exit $failed