Home | History | Annotate | Download | only in ftp
      1 #!/bin/sh
      2 #
      3 #   Copyright (c) International Business Machines  Corp., 2003
      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 #
     20 #
     21 #  FILE   : ftp
     22 #
     23 #  PURPOSE: Test to see if ftp rejects a user with an invalid password
     24 #
     25 #  HISTORY:
     26 #     03/03  Jerone Young (jeroney (at] us.ibm.com)
     27 #
     28 #  NOTE:
     29 #       This version is intended for EAL certification, it will need modification
     30 #       to conform with LTP standards in the offical LTP tree.
     31 #
     32 # DESCRIPTION:
     33 #	Create Test User
     34 #	Make sure test user cannont log in with invalid password
     35 #	Cleanup Test User from system
     36 #	Exit with exit code of script called upon
     37 #
     38 
     39 setup()
     40 {
     41 	export TEST_USER="ftpuser2"
     42 }
     43 
     44 do_test()
     45 {
     46 	CONNECTION_FAILED="Connection failed; test FAILED"
     47 	EXPECTED="Login failed as expected; test PASSED"
     48 	UNEXPECTED="Login succeeded unexpectedly; test FAILED"
     49 
     50 	set PASSWD "invaild_password?!!"
     51 	set timeout 90
     52 
     53 	expect -c "
     54 		#ftp to host
     55 		spawn ftp $RHOST
     56 		sleep 1
     57 		# Check if connection succeeded.
     58 		expect {
     59 			\"Name\" {}
     60 			timeout {send_user \"\n$CONNECTION_FAILED\n\";exit 1}
     61 		}
     62 
     63 		send \"$RUSER\r\"
     64 		sleep 1
     65 		expect -re \"Password:\"
     66 		send \"$PASSWD\r\"
     67 		sleep 1
     68 
     69 		expect {
     70 			# 530 - Login failed
     71 			\"530\" {send_user \"$EXPECTED\n\";exit 0}
     72 			# 230 - Login successful
     73 			\"230\" {send_user \"$UNEXPECTED\n\"; exit 1}
     74 		}
     75 
     76 		expect \"ftp>\"
     77 		send \"exit\r\"
     78 	"
     79 }
     80 
     81 TCID="ftp02"
     82 TST_TOTAL=1
     83 
     84 . test.sh
     85 . ftp_setup
     86 
     87 setup
     88 do_setup
     89 TST_CLEANUP=do_cleanup
     90 
     91 do_test
     92 if [ $? -ne 0 ]; then
     93 	tst_resm TFAIL "Test $TCID FAIL"
     94 else
     95 	tst_resm TPASS "Test $TCID PASS"
     96 fi
     97 
     98 tst_exit
     99