From ef1c18b952de0763037b7c940cc6960bbf990912 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 17 Mar 2011 16:59:30 -0700 Subject: Added support for LISTing a single POP3 message Added tests for a number of POP3 LIST operations, including one that shows a curl problem when listing no messages, so is disabled. --- tests/data/DISABLED | 1 + tests/data/Makefile.am | 3 ++- tests/data/test808 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/data/test809 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/data/test810 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/data/test811 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/ftpserver.pl | 24 ++++++++++++++++++++++++ 7 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 tests/data/test808 create mode 100644 tests/data/test809 create mode 100644 tests/data/test810 create mode 100644 tests/data/test811 (limited to 'tests') diff --git a/tests/data/DISABLED b/tests/data/DISABLED index b6071cbd9..9ac123b18 100644 --- a/tests/data/DISABLED +++ b/tests/data/DISABLED @@ -3,3 +3,4 @@ # per line. # Lines starting with '#' letters are treated as comments. 564 +811 diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index c3c68cae3..502abecc5 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -70,7 +70,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test313 test1115 test578 test579 test1116 test1200 test1201 test1202 \ test1203 test1117 test1118 test1119 test1120 test1300 test1301 test1302 \ test1303 test320 test321 test322 test323 test324 test1121 test581 test580 \ - test1304 test1305 test1306 test1307 test582 test583 + test1304 test1305 test1306 test1307 test582 test583 test808 test809 \ + test810 test811 filecheck: @mkdir test-place; \ diff --git a/tests/data/test808 b/tests/data/test808 new file mode 100644 index 000000000..756801c6b --- /dev/null +++ b/tests/data/test808 @@ -0,0 +1,41 @@ + + + +POP3 +LIST + + + +# +# Server-side + + +REPLY LIST +OK 808 100 + + + +# +# Client-side + + +pop3 + + +POP3 LIST one message + + +pop3://%HOSTIP:%POP3PORT/808 -l -u user:secret + + + +# +# Verify data after the test has been "shot" + + +USER user +PASS secret +LIST 808 +QUIT + + + diff --git a/tests/data/test809 b/tests/data/test809 new file mode 100644 index 000000000..29358e00c --- /dev/null +++ b/tests/data/test809 @@ -0,0 +1,45 @@ + + + +POP3 +LIST +FAILURE + + + +# +# Server-side + + +REPLY LIST -ERR no such message + + + +# +# Client-side + + +pop3 + + +POP3 LIST invalid message + + +pop3://%HOSTIP:%POP3PORT/809 -l -u user:secret + + + +# +# Verify data after the test has been "shot" + + +78 + + +USER user +PASS secret +LIST 809 +QUIT + + + diff --git a/tests/data/test810 b/tests/data/test810 new file mode 100644 index 000000000..d4f75972a --- /dev/null +++ b/tests/data/test810 @@ -0,0 +1,45 @@ + + + +POP3 +LIST + + + +# +# Server-side + +# When doing LIST, we get the default list output hard-coded in the test +# POP3 server + +1 100 +2 4294967400 +4 200 + + + +# +# Client-side + + +pop3 + + +POP3 LIST messages + + +pop3://%HOSTIP:%POP3PORT/ -u user:secret + + + +# +# Verify data after the test has been "shot" + + +USER user +PASS secret +LIST +QUIT + + + diff --git a/tests/data/test811 b/tests/data/test811 new file mode 100644 index 000000000..850e5e27d --- /dev/null +++ b/tests/data/test811 @@ -0,0 +1,43 @@ + + + +POP3 +LIST + + + +# +# Server-side + + +REPLY LIST +OK but no messages\r\n. + + + + + +# +# Client-side + + +pop3 + + +POP3 LIST no messages available + + +pop3://%HOSTIP:%POP3PORT/ -u user:secret + + + +# +# Verify data after the test has been "shot" + + +USER user +PASS secret +LIST +QUIT + + + diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index bbbf7be29..182511f13 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -392,6 +392,7 @@ sub protocolsetup { elsif($proto eq 'pop3') { %commandfunc = ( 'RETR' => \&RETR_pop3, + 'LIST' => \&LIST_pop3, ); %displaytext = ( 'USER' => '+OK We are happy you popped in!', @@ -683,6 +684,29 @@ sub RETR_pop3 { return 0; } +sub LIST_pop3 { + +# this is a built-in fake-message list +my @pop3list=( +"1 100\r\n", +"2 4294967400\r\n", # > 4 GB +"4 200\r\n", # Note that message 3 is a simulated "deleted" message +); + + logmsg "retrieve a message list\n"; + + sendcontrol "+OK Listing starts\r\n"; + + for my $d (@pop3list) { + sendcontrol $d; + } + + # end with the magic 5-byte end of listing marker + sendcontrol "\r\n.\r\n"; + + return 0; +} + ################ ################ FTP commands ################ -- cgit v1.2.3