xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbutil/tp_smbutil_013.ksh (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
25#
26
27#
28# ID: smbutil_013
29#
30# DESCRIPTION:
31#        Verify smbutil logout -a can works
32#
33# STRATEGY:
34#	1. run "smbutil login -c $TUSER"
35#	2. smbutil login and smbutil view can get right message
36#	3. smbutil logout -a can get right message
37#
38
39. $STF_SUITE/include/libtest.ksh
40
41tc_id="smbutil013"
42tc_desc="Verify smbutil login -a works"
43print_test_case $tc_id - $tc_desc
44
45if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
46	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
47    set -x
48fi
49
50server=$(server_name) || return
51
52# initialize
53sudo -n smbutil logoutall
54
55cmd="$EXPECT $SMBUTILEXP $TUSER \$TPASS"
56cti_execute_cmd $cmd
57if [[ $? != 0 ]]; then
58	cti_fail "FAIL: smbutil login failed to set password for user '$TUSER'"
59	return
60else
61	cti_report "PASS: smbutil login successfully set password for user '$TUSER'"
62fi
63
64cmd="smbutil login -c $TUSER | grep exists"
65cti_execute_cmd $cmd
66if [[ $? != 0 ]]; then
67	cti_fail "FAIL: keychain doesn't exist"
68	return
69else
70	cti_report "PASS: keychain exists"
71fi
72
73cmd="smbutil view //$TUSER@$server"
74cti_execute -i '' FAIL $cmd
75if [[ $? != 0 ]]; then
76	cti_fail "FAIL: smbutil can view the shares"
77	return
78else
79	cti_report "PASS: smbutil can't view the shares"
80fi
81
82parse_view_output public cti_stdout
83if [[ $? != 0 ]]; then
84	cti_fail "FAIL: smbutil view can't get the public share"
85	return
86else
87	cti_report "PASS: smbutil view can get the public share"
88fi
89
90cmd="$EXPECT $SMBUTILEXP $AUSER $APASS"
91cti_execute_cmd $cmd
92if [[ $? != 0 ]]; then
93	cti_fail "FAIL: smbutil login failed to set passwd to $AUSER"
94	return
95else
96	cti_report "PASS: smbutil login succeeded to set passwd to $AUSER"
97fi
98
99cmd="smbutil login -c $AUSER | grep exists"
100cti_execute_cmd $cmd
101if [[ $? != 0 ]]; then
102	cti_fail "FAIL: '$AUSER' keychain doesn't exist"
103	return
104else
105	cti_report "PASS: '$AUSER' keychain exists"
106fi
107
108cmd="smbutil view //$AUSER@$server"
109cti_execute -i '' FAIL $cmd
110if [[ $? != 0 ]]; then
111	cti_fail "FAIL: smbutil can't view shares"
112	return
113else
114	cti_report "PASS: smbutil can view shares"
115fi
116
117parse_view_output public cti_stdout
118if [[ $? != 0 ]]; then
119	cti_fail "FAIL: smbutil can't get the public share"
120	return
121else
122	cti_report "PASS: smbutil can get the public share"
123fi
124
125cti_execute_cmd "smbutil logout -a"
126if [[ $? != 0 ]]; then
127	cti_fail "FAIL: smbutil logout -a doesn't work"
128	return
129else
130	cti_report "smbutil logout -a works"
131fi
132
133cmd="smbutil login -c $TUSER | grep exists"
134cti_execute_cmd $cmd
135if [[ $? == 0 ]]; then
136	cti_fail "FAIL: '$TUSER' keychain exists"
137	return
138else
139	cti_report "PASS: '$TUSER' keychain doesn't exist"
140fi
141
142cmd="smbutil login -c $AUSER | grep exists"
143cti_execute_cmd $cmd
144if [[ $? == 0 ]]; then
145	cti_fail "FAIL: '$AUSER' keychain exists"
146	return
147else
148	cti_report "PASS: '$AUSER' keychain doesn't exist"
149fi
150
151cti_pass "${tc_id}: PASS"
152