]> granicus.if.org Git - curl/commitdiff
pop3 test server: allow pop3 test server verification to succeed again
authorYang Tse <yangsita@gmail.com>
Wed, 30 May 2012 15:39:14 +0000 (17:39 +0200)
committerYang Tse <yangsita@gmail.com>
Wed, 30 May 2012 15:39:14 +0000 (17:39 +0200)
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.

tests/data/test1319
tests/data/test1407
tests/data/test800
tests/data/test808
tests/data/test809
tests/data/test810
tests/data/test811
tests/data/test812
tests/data/test813
tests/data/test815
tests/ftpserver.pl

index d02ba653b1cdea60505cfaa10a6902132bce750c..8ca74cfdca04f7c75ff5ead9802a7354e873063a 100644 (file)
@@ -58,6 +58,7 @@ pop3://%HOSTIP:%POP3PORT/1319 -p -x %HOSTIP:%PROXYPORT -u user:secret
 ^User-Agent:
 </strip>
 <protocol>
+AUTH\r
 USER user\r
 PASS secret\r
 RETR 1319\r
index 0b40a4732a73e90625d36cbc75a3fe05c707151a..a8d911e0de0d93961f51de384aaab70bda824417 100644 (file)
@@ -34,6 +34,7 @@ pop3://%HOSTIP:%POP3PORT/1407 -l -u user:secret --libcurl log/test1407.c
 # Verify data after the test has been "shot"
 <verify>
 <protocol>
+AUTH\r
 USER user\r
 PASS secret\r
 LIST 1407\r
index 8c4850147657e61dca2f0815f8dd5177017da282..eebd27a443d7209779fe935e5c7998fb52195f7b 100644 (file)
@@ -38,6 +38,7 @@ pop3://%HOSTIP:%POP3PORT/800 -u user:secret
 # Verify data after the test has been "shot"
 <verify>
 <protocol>
+AUTH\r
 USER user\r
 PASS secret\r
 RETR 800\r
index 57e1382b1396ed1182c2271601cb394a4e5e3383..8f2526f258e04dc853eb4e3abacf9556e13214d9 100644 (file)
@@ -10,7 +10,6 @@ LIST
 # Server-side
 <reply>
 <servercmd>
-REPLY AUTH -ERR unsupported command\r
 REPLY LIST +OK 808 100
 </servercmd>
 </reply>
index 7cd04c891ab20db89c76822320cecbe5f7b84741..b16a1470e4f6f37ca3cc5717ca30905de7460bf4 100644 (file)
@@ -11,7 +11,6 @@ FAILURE
 # Server-side
 <reply>
 <servercmd>
-REPLY AUTH -ERR unsupported command\r
 REPLY LIST -ERR no such message
 </servercmd>
 </reply>
index 2e24c295b65c6387ea64eeda37eabedf5bcd5a65..e2f447eb1d457e381e3d24fd3eedcccaf77233c0 100644 (file)
@@ -13,7 +13,6 @@ LIST
 # packets
 <servercmd>
 SLOWDOWN
-REPLY AUTH -ERR unsupported command\r
 </servercmd>
 # When doing LIST, we get the default list output hard-coded in the test
 # POP3 server
index 06fa57dcb4abd4ed6526fa78ca5e0c2cdc0a174f..26a2906c7455d5262166d30835a7321f179507c2 100644 (file)
@@ -10,7 +10,6 @@ LIST
 # Server-side
 <reply>
 <servercmd>
-REPLY AUTH -ERR unsupported command\r
 REPLY LIST +OK but no messages\r\n.
 </servercmd>
 <datacheck>
index 9f1ba92964db972e9c9efbd535ea370e371dda63..0e0484d10d1ad48fd27708c7061c6e49ca5f6446 100644 (file)
@@ -11,7 +11,6 @@ FAILURE
 # Server-side
 <reply>
 <servercmd>
-REPLY AUTH -ERR unsupported command\r
 REPLY RETR -ERR no such message
 </servercmd>
 </reply>
index 13cfd7074be31b254c42ee627b11977ee3a9be50..780fdf170a33449e67b5690de3b16a80cd4aff46 100644 (file)
@@ -10,7 +10,6 @@ FAILURE
 # Server-side
 <reply>
 <servercmd>
-REPLY AUTH -ERR unsupported command\r
 REPLY PASS -ERR invalid login
 </servercmd>
 </reply>
index 9779fe690e56e4109ccb2a0ca73089774cc195af..c4170f0ca6d300f5d76cb8b1dc7113ec086e0eeb 100644 (file)
@@ -9,9 +9,6 @@ RETR
 #
 # Server-side
 <reply>
-<servercmd>\r
-REPLY AUTH -ERR unsupported command\r
-</servercmd>\r
 <data>
 From: me@somewhere\r
 To: fake@nowhere\r
index 034ac710daf1e10f87265c40816af0807623c1f9..c3728ef6c0ac077253846f6791ff5f5b7b6744f6 100755 (executable)
@@ -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)