aboutsummaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-05-30 17:39:14 +0200
committerYang Tse <yangsita@gmail.com>2012-05-30 17:39:14 +0200
commitb420f60a06c3910b2f36770f20559c2c4ec1548f (patch)
tree48ada3b673d8323c4ead59fcd8662064419d6e3f /tests/ftpserver.pl
parent7291c1f5654b1c433177207bfa7e21bb30fe5a50 (diff)
pop3 test server: allow pop3 test server verification to succeed again
Introduce SUPPORTCAPA and SUPPORTAUTH config commands to allow further pop3 test server expansion for tests that require CAPA or AUTH support, although this will need some extra work to make it fully functional.
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-xtests/ftpserver.pl68
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 034ac710d..c3728ef6c 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -138,6 +138,8 @@ my $nodataconn; # set if ftp srvr doesn't establish or accepts data channel
my $nodataconn425; # set if ftp srvr doesn't establish data ch and replies 425
my $nodataconn421; # set if ftp srvr doesn't establish data ch and replies 421
my $nodataconn150; # set if ftp srvr doesn't establish data ch and replies 150
+my $support_capa; # set if server supports capability command
+my $support_auth; # set if server supports authentication command
my %customreply; #
my %customcount; #
my %delayreply; #
@@ -555,6 +557,8 @@ sub protocolsetup {
}
elsif($proto eq 'pop3') {
%commandfunc = (
+ 'CAPA' => \&CAPA_pop3,
+ 'AUTH' => \&AUTH_pop3,
'RETR' => \&RETR_pop3,
'LIST' => \&LIST_pop3,
);
@@ -821,6 +825,50 @@ sub FETCH_imap {
################ POP3 commands
################
+sub CAPA_pop3 {
+ my ($testno) = @_;
+ my @data = ();
+
+ if(!$support_capa) {
+ push @data, "-ERR Unsupported command: 'CAPA'\r\n";
+ }
+ else {
+ push @data, "+OK List of capabilities follows\r\n";
+ push @data, "USER\r\n";
+ if($support_auth) {
+ push @data, "SASL UNKNOWN\r\n";
+ }
+ push @data, "IMPLEMENTATION POP3 pingpong test server\r\n";
+ push @data, ".\r\n";
+ }
+
+ for my $d (@data) {
+ sendcontrol $d;
+ }
+
+ return 0;
+}
+
+sub AUTH_pop3 {
+ my ($testno) = @_;
+ my @data = ();
+
+ if(!$support_auth) {
+ push @data, "-ERR Unsupported command: 'AUTH'\r\n";
+ }
+ else {
+ push @data, "+OK List of supported mechanisms follows\r\n";
+ push @data, "UNKNOWN\r\n";
+ push @data, ".\r\n";
+ }
+
+ for my $d (@data) {
+ sendcontrol $d;
+ }
+
+ return 0;
+}
+
sub RETR_pop3 {
my ($testno) = @_;
my @data;
@@ -1667,6 +1715,8 @@ sub customize {
$nodataconn425 = 0; # default is to not send 425 without data channel
$nodataconn421 = 0; # default is to not send 421 without data channel
$nodataconn150 = 0; # default is to not send 150 without data channel
+ $support_capa = 0; # default is to not support capability command
+ $support_auth = 0; # default is to not support authentication command
%customreply = (); #
%customcount = (); #
%delayreply = (); #
@@ -1731,6 +1781,14 @@ sub customize {
logmsg "FTPD: instructed to use NODATACONN\n";
$nodataconn=1;
}
+ elsif($_ =~ /SUPPORTCAPA/) {
+ logmsg "FTPD: instructed to support CAPABILITY command\n";
+ $support_capa=1;
+ }
+ elsif($_ =~ /SUPPORTAUTH/) {
+ logmsg "FTPD: instructed to support AUTHENTICATION command\n";
+ $support_auth=1;
+ }
elsif($_ =~ /NOSAVE/) {
# don't actually store the file we upload - to be used when
# uploading insanely huge amounts
@@ -2050,7 +2108,15 @@ while(1) {
if($check) {
logmsg "$FTPCMD wasn't handled!\n";
- sendcontrol "500 $FTPCMD is not dealt with!\r\n";
+ if($proto eq 'pop3') {
+ sendcontrol "-ERR $FTPCMD is not dealt with!\r\n";
+ }
+ elsif($proto eq 'imap') {
+ sendcontrol "$cmdid BAD $FTPCMD is not dealt with!\r\n";
+ }
+ else {
+ sendcontrol "500 $FTPCMD is not dealt with!\r\n";
+ }
}
} # while(1)