ssh01_s1 revision 073a34a7e7b4a3919ce122ecf2d6c56c864d43ca
1#! /usr/bin/expect -f
2#*********************************************************************
3#   Copyright (c) International Business Machines  Corp., 2000
4#
5#   This program is free software;  you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation; either version 2 of the License, or
8#   (at your option) any later version.
9#
10#   This program is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13#   the GNU General Public License for more details.
14#
15#   You should have received a copy of the GNU General Public License
16#   along with this program;  if not, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#
19#  FILE   : ssh
20#
21#  PURPOSE: Tests to see that ssh rejects an invalid password
22#
23#  SETUP: The program `/usr/bin/expect' MUST be installed.
24#
25#  HISTORY:
26#    03/03 Jerone Young (jeroney@us.ibm.com)
27#
28#
29set RHOST $env(RHOST)
30set TEST_USER $env(TEST_USER)
31set TEST_USER_PASSWD $env(TEST_USER_PASSWD)
32
33set RUSER $TEST_USER
34set PASSWD $TEST_USER_PASSWD
35
36set timeout 90
37
38#test invalid password
39
40send_user "TEST: SSH Test Invalid Password \n"
41
42# Set PASSWD to an invalid password
43set PASSWD "invalid_password!"
44
45spawn ssh -l $RUSER $RHOST whoami
46
47while 1 {
48	sleep 2
49	expect {
50
51		"Are you sure you want to continue connecting (yes/no)?" {
52			exp_send "yes\r"
53		}
54		"assword:" {
55			exp_send "$PASSWD\r"
56		}
57		-re "Permission denied (.*)\." {
58			send_user "SSH would not allow $RUSER to login with\
59				   invalid password, Test Passed \n"
60			send_user "\nTEST_PASSED\n"
61			exit 0
62		}
63		"$RUSER" {
64			send_user "SSH allowed $RUSER to login with invalid\
65				   pass, Test Failed \n"
66			exit 1
67		}
68	}
69	sleep 1
70}
71
72exit 1
73