Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / test / smbclient-tests / tests / smbutil / tp_smbutil_013.ksh
blobeef6a4b4788a8ed8e5865dc13b8b3d510a965103
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
28 # ID: smbutil_013
30 # DESCRIPTION:
31 # Verify smbutil logout -a can works
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
39 . $STF_SUITE/include/libtest.ksh
41 tc_id="smbutil013"
42 tc_desc="Verify smbutil login -a works"
43 print_test_case $tc_id - $tc_desc
45 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
46 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
47 set -x
50 server=$(server_name) || return
52 # initialize
53 sudo -n smbutil logoutall
55 cmd="$EXPECT $SMBUTILEXP $TUSER \$TPASS"
56 cti_execute_cmd $cmd
57 if [[ $? != 0 ]]; then
58 cti_fail "FAIL: smbutil login failed to set password for user '$TUSER'"
59 return
60 else
61 cti_report "PASS: smbutil login successfully set password for user '$TUSER'"
64 cmd="smbutil login -c $TUSER | grep exists"
65 cti_execute_cmd $cmd
66 if [[ $? != 0 ]]; then
67 cti_fail "FAIL: keychain doesn't exist"
68 return
69 else
70 cti_report "PASS: keychain exists"
73 cmd="smbutil view //$TUSER@$server"
74 cti_execute -i '' FAIL $cmd
75 if [[ $? != 0 ]]; then
76 cti_fail "FAIL: smbutil can view the shares"
77 return
78 else
79 cti_report "PASS: smbutil can't view the shares"
82 parse_view_output public cti_stdout
83 if [[ $? != 0 ]]; then
84 cti_fail "FAIL: smbutil view can't get the public share"
85 return
86 else
87 cti_report "PASS: smbutil view can get the public share"
90 cmd="$EXPECT $SMBUTILEXP $AUSER $APASS"
91 cti_execute_cmd $cmd
92 if [[ $? != 0 ]]; then
93 cti_fail "FAIL: smbutil login failed to set passwd to $AUSER"
94 return
95 else
96 cti_report "PASS: smbutil login succeeded to set passwd to $AUSER"
99 cmd="smbutil login -c $AUSER | grep exists"
100 cti_execute_cmd $cmd
101 if [[ $? != 0 ]]; then
102 cti_fail "FAIL: '$AUSER' keychain doesn't exist"
103 return
104 else
105 cti_report "PASS: '$AUSER' keychain exists"
108 cmd="smbutil view //$AUSER@$server"
109 cti_execute -i '' FAIL $cmd
110 if [[ $? != 0 ]]; then
111 cti_fail "FAIL: smbutil can't view shares"
112 return
113 else
114 cti_report "PASS: smbutil can view shares"
117 parse_view_output public cti_stdout
118 if [[ $? != 0 ]]; then
119 cti_fail "FAIL: smbutil can't get the public share"
120 return
121 else
122 cti_report "PASS: smbutil can get the public share"
125 cti_execute_cmd "smbutil logout -a"
126 if [[ $? != 0 ]]; then
127 cti_fail "FAIL: smbutil logout -a doesn't work"
128 return
129 else
130 cti_report "smbutil logout -a works"
133 cmd="smbutil login -c $TUSER | grep exists"
134 cti_execute_cmd $cmd
135 if [[ $? == 0 ]]; then
136 cti_fail "FAIL: '$TUSER' keychain exists"
137 return
138 else
139 cti_report "PASS: '$TUSER' keychain doesn't exist"
142 cmd="smbutil login -c $AUSER | grep exists"
143 cti_execute_cmd $cmd
144 if [[ $? == 0 ]]; then
145 cti_fail "FAIL: '$AUSER' keychain exists"
146 return
147 else
148 cti_report "PASS: '$AUSER' keychain doesn't exist"
151 cti_pass "${tc_id}: PASS"