From 84e7bb85b14e832c70e79c8b91b3ebe98f1dc2b1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 21 Jul 2007 21:48:58 +0000 Subject: [PATCH] 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! --- tests/ftpserver.pl | 71 +++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index c338e0d..b23efd9 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"; -- 2.7.4