aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-11 18:13:53 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-11 18:19:38 +0100
commitcfe5f7dbf431eee38cde62513aab59ddfbd058c8 (patch)
tree4790944938c9ba89a9b5b4978c495cfabea7a883 /tests
parent5840c918d5393876c651b32e875970613c95775d (diff)
ftpserver.pl: Added support for IMAP CLOSE and EXPUNGE commands
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ftpserver.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 9c4d15372..ac52a496c 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -585,9 +585,11 @@ sub protocolsetup {
'APPEND' => \&APPEND_imap,
'CAPABILITY' => \&CAPABILITY_imap,
'CHECK' => \&CHECK_imap,
+ 'CLOSE' => \&CLOSE_imap,
'CREATE' => \&CREATE_imap,
'DELETE' => \&DELETE_imap,
'EXAMINE' => \&EXAMINE_imap,
+ 'EXPUNGE' => \&EXPUNGE_imap,
'FETCH' => \&FETCH_imap,
'LIST' => \&LIST_imap,
'LOGOUT' => \&LOGOUT_imap,
@@ -1196,6 +1198,47 @@ sub CHECK_imap {
return 0;
}
+sub CLOSE_imap {
+ if ($selected eq "") {
+ sendcontrol "$cmdid BAD Command received in Invalid state\r\n";
+ }
+ elsif (!@deleted) {
+ sendcontrol "$cmdid BAD Command Argument\r\n";
+ }
+ else {
+ sendcontrol "$cmdid OK CLOSE completed\r\n";
+
+ @deleted = ();
+ }
+
+ return 0;
+}
+
+sub EXPUNGE_imap {
+ if ($selected eq "") {
+ sendcontrol "$cmdid BAD Command received in Invalid state\r\n";
+ }
+ else {
+ if (!@deleted) {
+ # Report the number of existing messages as per the SELECT
+ # command
+ sendcontrol "* 172 EXISTS\r\n";
+ }
+ else {
+ # Report the message UIDs being deleted
+ for my $d (@deleted) {
+ sendcontrol "* $d EXPUNGE\r\n";
+ }
+
+ @deleted = ();
+ }
+
+ sendcontrol "$cmdid OK EXPUNGE completed\r\n";
+ }
+
+ return 0;
+}
+
sub LOGOUT_imap {
sendcontrol "* BYE cURL IMAP server signing off\r\n";
sendcontrol "$cmdid OK LOGOUT completed\r\n";