| #! /usr/bin/expect -f |
| #********************************************************************* |
| # Copyright (c) International Business Machines Corp., 2003, 2005 |
| # |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| # the GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program; if not, write to the Free Software |
| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| # |
| # |
| # |
| # FILE : ftp |
| # |
| # PURPOSE: Test to see if ftp rejects a user with an invalid password |
| # |
| # SETUP: The program `/usr/bin/expect' MUST be installed. |
| # |
| # HISTORY: |
| # 03/04/03 Jerone Young (jeroney@us.ibm.com) |
| # 09/21/05 Kris Wilson (krisw@us.ibm.com) Check for connection failure. |
| # (If WS system, no vsftpd; connection will fail.) |
| |
| set RHOST $env(RHOST) |
| set TEST_USER $env(TEST_USER) |
| set TEST_USER_PASSWD $env(TEST_USER_PASSWD) |
| set TEST_USER_HOMEDIR $env(TEST_USER_HOMEDIR) |
| |
| #RUSER |
| set RUSER $TEST_USER |
| |
| #set PASSWD to be an invalid Password |
| set PASSWD "invaild_password?!!" |
| |
| set timeout 90 |
| |
| #ftp to host |
| spawn ftp $RHOST |
| sleep 1 |
| # Check if connection succeeded. |
| expect { |
| "Name" {} |
| timeout {send_user "\nConnection failed; test FAILED\n";exit 1} |
| } |
| |
| send "$RUSER\r" |
| sleep 1 |
| expect -re "Password:" |
| send "$PASSWD\r" |
| sleep 1 |
| |
| expect { |
| # 530 - Login failed |
| "530" {send_user "Login failed as expected; test PASSED\n"} |
| # 230 - Login successful |
| "230" {send_user "Login succeeded unexpectedly; test FAILED\n"; exit 1} |
| } |
| |
| expect "ftp>" |
| send "exit\r" |
| |
| send_user "\nTest Successful\n\n" |
| exit 0 |