diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-07-21 21:48:58 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-07-21 21:48:58 +0000 |
commit | 84e7bb85b14e832c70e79c8b91b3ebe98f1dc2b1 (patch) | |
tree | eed2dc81e5bf1980ab6fd1acf88c2ae3d019f535 | |
parent | 4fc7e13a98d699ae0a86f2af34131c1dca80b062 (diff) |
To allow more flexibility in FTP test cases, I've removed the enforced states
from the test server code as they served no real purpose. The test server is
here to serve for the test cases, not to attempt to function as a real server!
-rw-r--r-- | tests/ftpserver.pl | 71 |
1 files changed, 12 insertions, 59 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index c338e0dad..b23efd940 100644 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -230,44 +230,6 @@ sub senddata { } } -# USER is ok in fresh state -my %commandok = ( - 'USER' => 'fresh|passwd', - 'PASS' => 'passwd', - 'PASV' => 'loggedin|twosock', - 'EPSV' => 'loggedin|twosock', - 'PORT' => 'loggedin|twosock', - 'EPRT' => 'loggedin|twosock', - 'TYPE' => 'loggedin|twosock', - 'LIST' => 'twosock', - 'NLST' => 'twosock', - 'RETR' => 'twosock', - 'STOR' => 'twosock', - 'APPE' => 'twosock', - 'REST' => 'twosock', - 'ACCT' => 'loggedin', - 'CWD' => 'loggedin|twosock', - 'SYST' => 'loggedin', - 'SIZE' => 'loggedin|twosock', - 'PWD' => 'loggedin|twosock', - 'MKD' => 'loggedin|twosock', - 'QUIT' => 'loggedin|twosock', - 'RNFR' => 'loggedin|twosock', - 'RNTO' => 'loggedin|twosock', - 'DELE' => 'loggedin|twosock', - 'MDTM' => 'loggedin|twosock', - 'NOOP' => 'loggedin|twosock', - ); - -# initially, we're in 'fresh' state -my %statechange = ( 'USER' => 'passwd', # USER goes to passwd state - 'PASS' => 'loggedin', # PASS goes to loggedin state - 'PORT' => 'twosock', # PORT goes to twosock - 'EPRT' => 'twosock', # EPRT goes to twosock - 'PASV' => 'twosock', # PASV goes to twosock - 'EPSV' => 'twosock', # EPSV goes to twosock - ); - # this text is shown before the function specified below is run my %displaytext = ('USER' => '331 We are happy you popped in!', 'PASS' => '230 Welcome you silly person', @@ -285,6 +247,8 @@ my %displaytext = ('USER' => '331 We are happy you popped in!', 'RNFR' => '350 Received your order. Please provide more', 'RNTO' => '250 Ok, thanks. File renaming completed.', 'NOOP' => '200 Yes, I\'m very good at doing nothing.', + 'PBSZ' => '500 PBSZ not implemented', + 'PROT' => '500 PROT not implemented', ); # callback functions for certain commands @@ -809,7 +773,6 @@ while(1) { print STDERR "OUT: $_"; } } - my $state="fresh"; while(1) { my $i; @@ -856,24 +819,6 @@ while(1) { print STDERR "IN: $full\n"; } - my $ok = $commandok{$FTPCMD}; - if($ok !~ /$state/) { - sendcontrol "500 $FTPCMD not OK in state: $state!\r\n"; - next; - } - - my $newstate=$statechange{$FTPCMD}; - if($newstate eq "") { - # remain in the same state - } - else { - - if($state != $newstate) { - logmsg "switch to state $state\n"; - } - $state = $newstate; - } - my $delay = $delayreply{$FTPCMD}; if($delay) { # just go sleep this many seconds! @@ -893,19 +838,27 @@ while(1) { $customreply{$FTPCMD}=""; } } + my $check; if($text) { sendcontrol "$text\r\n"; } + else { + $check=1; # no repsonse yet + } if($fake eq "") { # only perform this if we're not faking a reply - # see if the new state is a function caller. my $func = $commandfunc{$FTPCMD}; if($func) { - # it is! &$func($FTPARG, $FTPCMD); + $check=0; # taken care of } } + + if($check) { + print STDERR "$FTPCMD wasn't handled!\n"; + sendcontrol "500 $FTPCMD is not dealt with!\r\n"; + } } # while(1) logmsg "====> Client disconnected\n"; |