Commit 759cf45a 759cf45adacfe54b505ad7deebf3e54602ce46f0 by Sergey Poznyakoff

imap4d: reimplement fetch tests in Autotest. Remove DejaGNU-based testsuite.

* configure.ac: Update.
* imap4d/Makefile.am (SUBDIRS): Remove testsuite.
* imap4d/fetch.c (fetch_thunk): Add a FIXME reference.
* imap4d/tests/fetch.at: New file.
* imap4d/tests/Makefile.am (TESTSUITE_AT): Add fetch.at
* imap4d/tests/testsuite.at: Include fetch.at
* imap4d/tests/atlocal.in (fixup_tz): New filter.
* imap4d/tests/Makefile.am (EXTRA_DIST): Remove unexisting file.
* imap4d/testsuite: Remove
1 parent fb32f889
......@@ -1438,7 +1438,6 @@ AC_CONFIG_FILES([
frm/Makefile
scheme/Makefile
imap4d/Makefile
imap4d/testsuite/Makefile
include/Makefile
include/mailutils/Makefile
include/mailutils/sys/Makefile
......
......@@ -16,7 +16,7 @@
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@
SUBDIRS = tests testsuite
SUBDIRS = tests
sbin_PROGRAMS = imap4d
......
......@@ -1728,7 +1728,11 @@ fetch_thunk (imap4d_parsebuf_t pb)
Obviously the same holds true for non-existing message numbers
as well, although I did not find any explicit mention thereof
in the RFC. */
in the RFC.
FIXME: This code also causes imap4d to silently ignore erroneous
msgset specifications (e.g. FETCH foobar (FLAGS)), which should
be fixed. */
pb->err_text = "Completed";
return RESP_OK;
......
......@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
......@@ -46,6 +46,7 @@ TESTSUITE_AT = \
create02.at\
examine.at\
expunge.at\
fetch.at\
id.at\
IDEF0955.at\
IDEF0956.at\
......
......@@ -17,10 +17,14 @@ remove_uidvalidity() {
sed '/^\* OK \[UIDVALIDITY/d'
}
remove_select_unagged() {
remove_select_untagged() {
sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
}
fixup_tz() {
sed '/^\* [0-9][0-9]* FETCH/s/ [+-][0-9][0-9][0-9][0-9]"/ +0000"/'
}
sorted_list_output() {
sed '/^\* PREAUTH/d
/^\* OK/d
......
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1],[FILTERS=`'])
m4_define([FETCH_CHECK],[
AT_SETUP([$1])
AT_KEYWORDS([fetch $2])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/m4_if([$5],,mbox1,[$5]),INBOX)
],
[1 SELECT INBOX
2 FETCH $3
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
$4
2 OK FETCH Completed
* BYE Session terminating.
X OK LOGOUT Completed
],
[],
[remove_select_untagged[]m4_if([$6],,,|[$6])])
AT_CLEANUP
])
dnl ----------------------------------------------------------------------
# 6.4.5. FETCH Command
# Arguments: message set
# message data item names
# Responses: untagged responses: FETCH
# Result: OK - fetch completed
# NO - fetch error: can't fetch that data
# BAD - command unknown or arguments invalid
#
# The FETCH command retrieves data associated with a message in the
# mailbox. The data items to be fetched can be either a single atom
# or a parenthesized list.
# FLAGS The flags that are set for this message.
FETCH_CHECK([flags],[fetch-flags fetch00],
[3 (FLAGS)],
[* 3 FETCH (FLAGS (\Recent))])
# INTERNALDATE The internal date of the message.
FETCH_CHECK([internaldate],[fetch-internaldate fetch01],
[3 INTERNALDATE],
[* 3 FETCH (INTERNALDATE "13-Jul-2002 00:43:18 +0000")],
[],
[fixup_tz])
# UID The unique identifier for the message.
FETCH_CHECK([uid],[fetch-uid fetch02],
[3 UID],
[* 3 FETCH (UID 3)])
FETCH_CHECK([uid + internaldate],[fetch-internaldate-uid fetch03],
[3 (FLAGS INTERNALDATE UID)],
[* 3 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" UID 3)],
[],
[fixup_tz])
# ENVELOPE The envelope structure of the message. This is
# computed by the server by parsing the [RFC-822]
# header into the component parts, defaulting various
# fields as necessary.
FETCH_CHECK([envelope],[fetch-envelope fetch04],
[1:* ENVELOPE],
[* 1 FETCH (ENVELOPE ("Fri, 28 Dec 2001 22:18:08 +0200" "Jabberwocky" (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Bar" NIL "bar" "dontmailme.org")) NIL NIL NIL "<200112282018.fBSKI8N04906@nonexistent.net>"))
* 2 FETCH (ENVELOPE ("Fri, 28 Dec 2001 23:28:08 +0200" "Re: Jabberwocky" (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200112232808.fERKR9N16790@dontmailme.org>"))
* 3 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Simple MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))
* 4 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>"))
* 5 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Empty MIME Parts" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))])
# ALL Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE ENVELOPE)
FETCH_CHECK([ALL],[fetch-all fetch05],
[1:* ALL],
[* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298 ENVELOPE ("Fri, 28 Dec 2001 22:18:08 +0200" "Jabberwocky" (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Bar" NIL "bar" "dontmailme.org")) NIL NIL NIL "<200112282018.fBSKI8N04906@nonexistent.net>"))
* 2 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 23:28:09 +0000" RFC822.SIZE 547 ENVELOPE ("Fri, 28 Dec 2001 23:28:08 +0200" "Re: Jabberwocky" (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200112232808.fERKR9N16790@dontmailme.org>"))
* 3 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" RFC822.SIZE 1611 ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Simple MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))
* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>"))
* 5 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" RFC822.SIZE 884 ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Empty MIME Parts" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))],
[],
[fixup_tz])
# BODYSTRUCTURE The [MIME-IMB] body structure of the message. This
# is computed by the server by parsing the [MIME-IMB]
# header fields in the [RFC-822] header and
# [MIME-IMB] headers.
FETCH_CHECK([BODYSTRUCTURE],[fetch-bodystructure fetch06],
[1:* BODYSTRUCTURE],
[* 1 FETCH (BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 972 35 NIL NIL NIL))
* 2 FETCH (BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 219 4 NIL NIL NIL))
* 3 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "msg.1" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "How doth" "7BIT" 239 9 NIL NIL NIL)("application" "octet-stream" ("name" "msg.21") "<5082.1026510189.2@example.net>" "Father William Part I" "base64" 468 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))
* 4 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10 NIL NIL NIL)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486 NIL NIL NIL)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490 NIL NIL NIL)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa2") NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa1") NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))
* 5 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "empty" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "Empty part" "7BIT" 0 0 NIL NIL NIL)("text" "plain" ("name" "single.line" "charset" "us-ascii") "<5082.1026510189.2@example.net>" "Single line part" "7BIT" 2 1 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))])
# BODY
# Non-extensible form of BODYSTRUCTURE.
FETCH_CHECK([BODY],[fetch-body fetch07],
[1:* BODY],
[* 1 FETCH (BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 972 35))
* 2 FETCH (BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 219 4))
* 3 FETCH (BODY (("text" "plain" ("name" "msg.1" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "How doth" "7BIT" 239 9)("application" "octet-stream" ("name" "msg.21") "<5082.1026510189.2@example.net>" "Father William Part I" "base64" 468) "mixed" NIL NIL NIL))
* 4 FETCH (BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))
* 5 FETCH (BODY (("text" "plain" ("name" "empty" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "Empty part" "7BIT" 0 0)("text" "plain" ("name" "single.line" "charset" "us-ascii") "<5082.1026510189.2@example.net>" "Single line part" "7BIT" 2 1) "mixed" NIL NIL NIL))])
# BODY[<section>]<<partial>>
# The text of a particular body section. The section
# specification is a set of zero or more part specifiers
# delimited by periods. A part specifier is either a part number
# or one of the following: HEADER, HEADER.FIELDS,
# HEADER.FIELDS.NOT, MIME, and TEXT. An empty section
# specification refers to the entire message, including the
# header.
# The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT
# part specifiers refer to the [RFC-822] header of
# the message or of an encapsulated [MIME-IMT]
# MESSAGE/RFC822 message.
FETCH_CHECK([BODY[[HEADER]]],[fetch-body-header fetch08],
[1 BODY[[HEADER]]],
[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER]] {326}
Received: (from foobar@nonexistent.net)
by nonexistent.net id fBSKI8N04906
for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 22:18:08 +0200
From: Foo Bar <foobar@nonexistent.net>
Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
To: Bar <bar@dontmailme.org>
Subject: Jabberwocky
)])
# HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of
# field-name (as defined in [RFC-822]) names, and return a subset
# of the header.
# The subset returned by HEADER.FIELDS contains only those header fields
# with a field-name that matches one of the names in the list;
FETCH_CHECK([BODY[[HEADER.FIELDS]]],[fetch-body-header-fields fetch09],
[1 BODY[[HEADER.FIELDS (FROM TO SUBJECT)]]],
[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER.FIELDS (FROM TO SUBJECT)]] {94}
FROM: Foo Bar <foobar@nonexistent.net>
TO: Bar <bar@dontmailme.org>
SUBJECT: Jabberwocky
)])
# similarly, the subset returned by HEADER.FIELDS.NOT contains only
# the header fields with a non-matching field-name.
FETCH_CHECK([BODY[[HEADER.FIELDS.NOT]]],[fetch-body-header-fields-not fetch10],
[1 BODY[[HEADER.FIELDS.NOT (FROM TO SUBJECT)]]],
[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER.FIELDS.NOT (FROM TO SUBJECT)]] {234}
Received: (from foobar@nonexistent.net)
by nonexistent.net id fBSKI8N04906
for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 22:18:08 +0200
Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
)])
# The TEXT part specifier refers to the text body of
# the message, omitting the [RFC-822] header.
FETCH_CHECK([BODY[[TEXT]]],[fetch-body-text fetch11],
[1 BODY[[TEXT]]],
[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]] {972}
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
`Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jujub bird, and shun
The frumious Bandersnatch!'
He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum gree,
And stood awhile in thought.
And as in uffish thought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wook,
And burbled as it came!
One, two! One, two! And through and through
The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.
`And has thou slain the Jabberwock?
Come to my arms, my beamish boy!
O frabjous day! Calloh! Callay!
He chortled in his joy.
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
)])
# It is possible to fetch a substring of the
# designated text. This is done by appending an open
# angle bracket ("<"), the octet position of the
# first desired octet, a period, the maximum number
# of octets desired, and a close angle bracket (">")
# to the part specifier.
FETCH_CHECK([BODY[[TEXT]]<X.Y>],[fetch-body-text-substring fetch12],
[1 BODY[[TEXT]]<0.20>],
[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<0> {20}
`Twas brillig, and t)])
FETCH_CHECK([BODY[[TEXT]]<Y.X>],[fetch-body-text-rev-substring fetch13],
[1 BODY[[TEXT]]<200.100>],
[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<200> {100}
t catch!
Beware the Jujub bird, and shun
The frumious Bandersnatch!'
He took his vorpal sword i)])
# If the starting octet is beyond the end of
# the text, an empty string is returned.
FETCH_CHECK([BODY[[TEXT]]<X-too-big>],[fetch-body-text-off2big fetch14],
[1 BODY[[TEXT]]<3900.4000>],
[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<3900> "")])
# Any partial fetch that attempts to read beyond the
# end of the text is truncated as appropriate. A
# partial fetch that starts at octet 0 is returned as
# a partial fetch, even if this truncation happened.
#
# Note: this means that BODY[]<0.2048> of a 1500-octet
# message will return BODY[]<0> with a literal of size 1500,
# not BODY[].
FETCH_CHECK([BODY[[TEXT]] (truncated)],[fetch-body-text-truncated fetch15],
[1 BODY[[TEXT]]<0.4000>],
[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<0> {972}
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
`Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jujub bird, and shun
The frumious Bandersnatch!'
He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum gree,
And stood awhile in thought.
And as in uffish thought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wook,
And burbled as it came!
One, two! One, two! And through and through
The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.
`And has thou slain the Jabberwock?
Come to my arms, my beamish boy!
O frabjous day! Calloh! Callay!
He chortled in his joy.
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
)])
# The MIME part specifier refers to the [MIME-IMB]
# header for this part.
# The MIME part specifier MUST be prefixed by one or
# more numeric part specifiers.
FETCH_CHECK([BODY[[N.MIME]]],[fetch-body-mime fetch16],
[3 BODY[[1.MIME]]],
[* 3 FETCH (FLAGS (\Seen) BODY[[1.MIME]] {138}
Content-Type: text/plain; name="msg.1"; charset="us-ascii"
Content-ID: <5082.1026510189.1@example.net>
Content-Description: How doth
)])
FETCH_CHECK([BODY[[<section>]]],[fetch-body-section fetch17],
[4 BODY[[2.2.1]]],
[* 4 FETCH (FLAGS (\Seen) BODY[[2.2.1]] {490}
YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh
awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv
b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn
ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g
dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1
bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz
dCBvZiBteSBsaWZlLicK
)])
# BODY.PEEK[<section>]<<partial>>
# An alternate form of BODY[<section>] that does not
# implicitly set the \Seen flag.
FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch18],
[1 BODY.PEEK[[HEADER]]],
[* 1 FETCH (BODY[[HEADER]] {326}
Received: (from foobar@nonexistent.net)
by nonexistent.net id fBSKI8N04906
for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 22:18:08 +0200
From: Foo Bar <foobar@nonexistent.net>
Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
To: Bar <bar@dontmailme.org>
Subject: Jabberwocky
)])
# RFC822 Functionally equivalent to BODY[], differing in the
# syntax of the resulting untagged FETCH data (RFC822
# is returned).
FETCH_CHECK([RFC822],[fetch-rfc822 fetch19],
[1 RFC822],
[* 1 FETCH (FLAGS (\Seen) RFC822 {1298}
Received: (from foobar@nonexistent.net)
by nonexistent.net id fBSKI8N04906
for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 22:18:08 +0200
From: Foo Bar <foobar@nonexistent.net>
Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
To: Bar <bar@dontmailme.org>
Subject: Jabberwocky
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
`Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jujub bird, and shun
The frumious Bandersnatch!'
He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum gree,
And stood awhile in thought.
And as in uffish thought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wook,
And burbled as it came!
One, two! One, two! And through and through
The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.
`And has thou slain the Jabberwock?
Come to my arms, my beamish boy!
O frabjous day! Calloh! Callay!
He chortled in his joy.
`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
)])
# RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER],
# differing in the syntax of the resulting untagged
# FETCH data (RFC822.HEADER is returned).
# FIXME: Should it set \Seen flag?
FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch20],
[2 RFC822.HEADER],
[* 2 FETCH (RFC822.HEADER {328}
Received: (from bar@dontmailme.org)
by dontmailme.org id fERKR9N16790
for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 23:28:08 +0200
From: Bar <bar@dontmailme.org>
To: Foo Bar <foobar@nonexistent.net>
Message-Id: <200112232808.fERKR9N16790@dontmailme.org>
Subject: Re: Jabberwocky
)])
# RFC822.SIZE The [RFC-822] size of the message.
FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch21],
[3 RFC822.SIZE],
[* 3 FETCH (RFC822.SIZE 1611)])
# RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in
# the syntax of the resulting untagged FETCH data
# (RFC822.TEXT is returned).
FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text fetch22],
[2 RFC822.TEXT],
[* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219}
It seems very pretty, but it's *rather* hard to understand!'
Somehow it seems to fill my head with ideas -- only I don't
exactly know what they are! However, SOMEBODY killed SOMETHING:
that's clear, at any rate...
)])
# FAST Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE)
FETCH_CHECK([FAST],[fetch-fast fetch23],
[1 FAST],
[* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)],
[],
[fixup_tz])
# FULL Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE ENVELOPE BODY)
FETCH_CHECK([FULL],[fetch-full fetch24],
[4 FULL],
[* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))],
[],
[fixup_tz])
dnl ----------------------------------------------------------------------
......@@ -32,7 +32,7 @@ X LOGOUT
X OK LOGOUT Completed
],
[],
[remove_select_unagged])
[remove_select_untagged])
AT_CLEANUP
])
......
......@@ -83,6 +83,9 @@ m4_include([list.at])
AT_BANNER([SEARCH])
m4_include([search.at])
AT_BANNER([FETCH])
m4_include([fetch.at])
AT_BANNER([IDEF Checks])
m4_include([IDEF0955.at])
m4_include([IDEF0956.at])
......
Makefile
Makefile.in
*.log
*.sum
imap4d.rc
site.exp
remote.exp
data
## This file is part of GNU Mailutils.
## Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
## Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3, or (at
## your option) any later version.
##
## GNU Mailutils is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = dejagnu
DEJATOOL = imap4d
RUNTESTFLAGS =
CLEANFILES = *.log imap4d.rc
EXTRA_DIST = imap4d.rcin
test_dirs = lib imap4d config
dist-hook:
here=`cd $(top_builddir)/$(subdir) && pwd`; \
srcdir=`cd $(srcdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
for dir in $(test_dirs); \
do \
cd $$srcdir;\
mkdir $$distdir/$$dir;\
cd $$dir;\
for file in DISTFILES `cat DISTFILES`; do \
d=$$srcdir/$$dir; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $$distdir/$$dir/$$file; \
else \
test -f $$distdir/$$dir/$$file \
|| cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
fi; \
done;\
done;\
cd $$here
site.exp: Makefile remote.exp
@echo 'Making a new site.exp file...'
@test ! -f site.bak || rm -f site.bak
@echo '## these variables are automatically generated by make ##' > $@-t
@echo '# Do not edit here. If you wish to override these values' >> $@-t
@echo '# edit the last section' >> $@-t
@echo 'set tool $(DEJATOOL)' >> $@-t
@echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
@echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
@echo 'set objdir' `pwd` >> $@-t
@echo 'set host_alias "$(host_alias)"' >> $@-t
@echo 'set host_triplet $(host_triplet)' >> $@-t
@echo 'set target_alias "$(target_alias)"' >> $@-t
@echo 'set target_triplet $(target_triplet)' >> $@-t
@echo 'set build_alias "$(build_alias)"' >> $@-t
@echo 'set build_triplet $(build_triplet)' >> $@-t
@echo 'set MU_ULONG_MAX $(MU_ULONG_MAX)' >> $@-t
@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
@test ! -f site.exp || mv site.exp site.bak
@mv $@-t site.exp
remote.exp:;
@echo 'Making a new remote.exp file...'
@test ! -f remote.bak || rm -f remote.bak
@echo '## These variables are used to set up for the remote testing.' >> $@-t
@echo '## Please, read file README in this directory for instructions' >> $@-t
@echo '## on how to use this file' >> $@-t
@echo "set host_board `hostname`" >> $@-t
@echo 'set board_info($$host_board,connect) rlogin' >> $@-t
@echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
@test ! -f remote.exp || mv remote.exp remote.bak
@mv $@-t remote.exp
DISTCLEANFILES=*.exp *.log *.sum
distclean-local:
-rm -rf data
# Configuration file for Mailutils Imap4d testsuite.
# Copyright (C) 2008, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
mailbox {
mail-spool "$objdir/data/spool";
mailbox-pattern "$objdir/data/spool/INBOX";
}
auth {
authentication generic;
authorization virtdomain;
}
virtdomain {
passwd-dir "$objdir/data/etc";
}
shared-namespace "$objdir/data";
logging {
syslog no;
print-severity yes;
};
IDEF0955.exp
IDEF0956.exp
anystate.exp
append.exp
create.exp
examine.exp
expunge.exp
fetch.exp
list.exp
search.exp
x.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2005, 2007, 2008, 2010, 2011 Free Software Foundation,
# Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# Mailutils versions prior to 0.6.1 allowed to use any numbers in message
# sets, even those greater than the maximum id (message number or uid),
# available in the mailbox.
# Reported: by idefense.com on Thu, 12 May 2005 13:30:06 -0400
# References: <FB24803D1DF2A34FA59FC157B77C9705043322C1@IDSERV04.idef.com>
if { $MU_ULONG_MAX > 0 } {
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
set limit [expr $MU_ULONG_MAX - 1]
verbose "LIMIT is $limit"
imap4d_test "FETCH 1:$limit FLAGS" \
"OK"
imap4d_test "UID FETCH 1:$limit FLAGS" \
"OK"
} else {
unsupported "IDEF0955";
}
# End of IDEF0955.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# Mailutils versions prior to 0.6.1 missed check for integer overflow
# in fetch_io.
# Reported: by idefense.com on Thu, 12 May 2005 13:30:04 -0400
# References: <FB24803D1DF2A34FA59FC157B77C9705043322C0@IDSERV04.idef.com>
if { $MU_ULONG_MAX > 0 } {
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
set limit [expr $MU_ULONG_MAX - 1]
verbose "LIMIT is $limit"
imap4d_test "FETCH 1 BODY\[TEXT\]<0.$limit>" \
"BAD FETCH Completed"
} else {
unsupported "IDEF0956"
}
# End of IDEF0956.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
# Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
imap4d_start
imap4d_test "CAPABILITY" \
"CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT" \
"OK"
imap4d_test "NOOP"
imap4d_test "NAMESPACE" "BAD"
imap4d_stop
# End of anystate.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# 6.3.11. APPEND Command
# Arguments: mailbox name
# OPTIONAL flag parenthesized list
# OPTIONAL date/time string
# message literal
# Responses: no specific responses for this command
# Result: OK - append completed
# NO - append error: can't append to that mailbox, error
# in flags or date/time or message text
# BAD - command unknown or arguments invalid
#
# The APPEND command appends the literal argument as a new message
# to the end of the specified destination mailbox. This argument
# SHOULD be in the format of an [RFC-822] message.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test -long "APPEND mbox (\\Seen)"\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0100000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Hello Joe, do you think we can meet at 3:30 tomorrow?
"
imap4d_test -long "APPEND mbox \"25-Aug-2002 18:00:00 +0200\""\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting again
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0200000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Better yet at 04:00?
"
imap4d_test "SELECT mbox"\
"3 EXISTS"\
"3 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 4\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK"
imap4d_test "FETCH 2:3 BODY\[\]"\
"2 FETCH (FLAGS (\\Seen) BODY\[\] {312}"\
-literal\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
"From: Fred Foobar <foobar@Blurdybloop.COM>"\
"Subject: afternoon meeting"\
"To: mooch@owatagu.siam.edu"\
"Message-Id: <B27397-0100000@Blurdybloop.COM>"\
"MIME-Version: 1.0"\
"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
""\
"Hello Joe, do you think we can meet at 3:30 tomorrow?"\
""\
")"\
-noliteral\
"3 FETCH (FLAGS (\\Seen) BODY\[\] {285}"\
-literal\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
"From: Fred Foobar <foobar@Blurdybloop.COM>"\
"Subject: afternoon meeting again"\
"To: mooch@owatagu.siam.edu"\
"Message-Id: <B27397-0200000@Blurdybloop.COM>"\
"MIME-Version: 1.0"\
"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
""\
"Better yet at 04:00?"\
")"\
"OK"
imap4d_stop
# End of append.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# 6.3.3. CREATE Command
# Arguments: mailbox name
# Responses: no specific responses for this command
# Result: OK - create completed
# NO - create failure: can't create mailbox with that name
# BAD - command unknown or arguments invalid
#
# The CREATE command creates a mailbox with the given name. An OK
# response is returned only if a new mailbox with that name has been
# created. It is an error to attempt to create INBOX or a mailbox
# with a name that refers to an extant mailbox. Any error in
# creation will return a tagged NO response.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "CREATE flat"
imap4d_test "CREATE en/to/tre"
imap4d_test -long "APPEND en/to/tre \"25-Aug-2002 18:00:00 +0200\""\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting again
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0200000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Better yet at 04:00?
"
# If the server's hierarchy separator character appears elsewhere in
# the name, the server SHOULD create any superior hierarchical names
# that are needed for the CREATE command to complete successfully.
imap4d_test "SELECT en/to/tre"\
"1 EXISTS"\
"1 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 2\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
imap4d_test "FETCH 1 ALL"\
-re {1 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"25-Aug-2002 16:00:00 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 285 ENVELOPE \(\"Mon, 7 Feb 1994 21:52:25 -0800 \(PST\)\" \"afternoon meeting again\" \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(NIL NIL \"mooch\" \"owatagu.siam.edu\"\)\) NIL NIL NIL \"<B27397-0200000@Blurdybloop.COM>\"\)\)}\
"OK"
imap4d_stop
# End of create.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
# Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "EXAMINE INBOX"\
"95 EXISTS"\
"95 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 96\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
"OK \[READ-ONLY\] EXAMINE Completed"
imap4d_test "SELECT INBOX"\
"95 EXISTS"\
"95 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 96\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage "\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \
-re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96\)} \
"OK"
imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \
"STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6)" \
"OK"
imap4d_test "EXAMINE mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
"OK \[READ-ONLY\] EXAMINE Completed"
imap4d_stop
# End of examine.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# 6.4.3. EXPUNGE Command
# Arguments: none
# Responses: untagged responses: EXPUNGE
# Result: OK - expunge completed
# NO - expunge failure: can't expunge (e.g. permission
# denied)
# BAD - command unknown or arguments invalid
#
# The EXPUNGE command permanently removes from the currently
# selected mailbox all messages that have the \Deleted flag set.
# Before returning an OK to the client, an untagged EXPUNGE response
# is sent for each message that is removed.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
imap4d_test "STORE 2:* +FLAGS (\\Deleted)"\
"2 FETCH (FLAGS (\\Deleted \\Recent))"\
"3 FETCH (FLAGS (\\Deleted \\Recent))"\
"4 FETCH (FLAGS (\\Deleted \\Recent))"\
"5 FETCH (FLAGS (\\Deleted \\Recent))"\
"OK"
imap4d_test "EXPUNGE"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"1 EXISTS"\
"1 RECENT"\
"OK"
imap4d_test "CLOSE"
imap4d_test "SELECT mbox1" \
"1 EXISTS"\
"0 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
imap4d_stop
# End of expunge.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# 6.4.5. FETCH Command
# Arguments: message set
# message data item names
# Responses: untagged responses: FETCH
# Result: OK - fetch completed
# NO - fetch error: can't fetch that data
# BAD - command unknown or arguments invalid
#
# The FETCH command retrieves data associated with a message in the
# mailbox. The data items to be fetched can be either a single atom
# or a parenthesized list.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
# FLAGS The flags that are set for this message.
imap4d_test "FETCH 3 (FLAGS)"\
"3 FETCH (FLAGS (\\Recent))"\
"OK"
# INTERNALDATE The internal date of the message.
imap4d_test "FETCH 3 INTERNALDATE"\
-re {3 FETCH \(INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\"\)} \
"OK"
# UID The unique identifier for the message.
imap4d_test "FETCH 3 UID"\
"3 FETCH (UID 3)"\
"OK"
imap4d_test "FETCH 3 (FLAGS INTERNALDATE UID)"\
-re {3 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" UID 3\)}\
"OK"
# ENVELOPE The envelope structure of the message. This is
# computed by the server by parsing the [RFC-822]
# header into the component parts, defaulting various
# fields as necessary.
imap4d_test "FETCH 1:* ENVELOPE"\
"1 FETCH (ENVELOPE (\"Fri, 28 Dec 2001 22:18:08 +0200\" \"Jabberwocky\" ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) NIL NIL NIL \"<200112282018.fBSKI8N04906@nonexistent.net>\"))"\
"2 FETCH (ENVELOPE (\"Fri, 28 Dec 2001 23:28:08 +0200\" \"Re: Jabberwocky\" ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200112232808.fERKR9N16790@dontmailme.org>\"))"\
"3 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:43:18 +0300\" \"Simple MIME\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"))"\
"4 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:50:58 +0300\" \"Nested MIME\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"))"\
"5 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:43:18 +0300\" \"Empty MIME Parts\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"))"\
"OK"
# ALL Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE ENVELOPE)
imap4d_test "FETCH 1:\* ALL"\
-re {1 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"28-Dec-2001 22:18:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1298 ENVELOPE \(\"Fri, 28 Dec 2001 22:18:08 \+0200\" \"Jabberwocky\" \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) NIL NIL NIL \"<200112282018.fBSKI8N04906@nonexistent.net>\"\)\)}\
-re {2 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"28-Dec-2001 23:28:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 547 ENVELOPE \(\"Fri, 28 Dec 2001 23:28:08 \+0200\" \"Re: Jabberwocky\" \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200112232808.fERKR9N16790@dontmailme.org>\"\)\)}\
-re {3 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1611 ENVELOPE \(\"Sat, 13 Jul 2002 00:43:18 \+0300\" \"Simple MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"\)\)}\
-re {4 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:50:58 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 3483 ENVELOPE \(\"Sat, 13 Jul 2002 00:50:58 \+0300\" \"Nested MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"\)\)}\
-re {5 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 884 ENVELOPE \(\"Sat, 13 Jul 2002 00:43:18 \+0300\" \"Empty MIME Parts\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"\)\)}\
"OK"
# BODYSTRUCTURE The [MIME-IMB] body structure of the message. This
# is computed by the server by parsing the [MIME-IMB]
# header fields in the [RFC-822] header and
# [MIME-IMB] headers.
imap4d_test "FETCH 1 BODYSTRUCTURE"\
"1 FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 972 35 NIL NIL NIL))"\
"OK"
imap4d_test "FETCH 2 BODYSTRUCTURE"\
"2 FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 219 4 NIL NIL NIL))"\
"OK"
imap4d_test "FETCH 3 BODYSTRUCTURE"\
"3 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"msg.1\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"How doth\" \"7BIT\" 239 9 NIL NIL NIL)(\"application\" \"octet-stream\" (\"name\" \"msg.21\") \"<5082.1026510189.2@example.net>\" \"Father William Part I\" \"base64\" 468 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
"OK"
imap4d_test "FETCH 4 BODYSTRUCTURE"\
"4 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"msg.21\" \"charset\" \"us-ascii\") \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10 NIL NIL NIL)((\"application\" \"octet-stream\" (\"name\" \"msg.22\") \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486 NIL NIL NIL)((\"application\" \"octet-stream\" (\"name\" \"msg.23\") \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490 NIL NIL NIL)(\"application\" \"octet-stream\" (\"name\" \"msg.24\") \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa2\") NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa1\") NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
"OK"
imap4d_test "FETCH 5 BODYSTRUCTURE"\
"5 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"empty\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"Empty part\" \"7BIT\" 0 0 NIL NIL NIL)(\"text\" \"plain\" (\"name\" \"single.line\" \"charset\" \"us-ascii\") \"<5082.1026510189.2@example.net>\" \"Single line part\" \"7BIT\" 2 1 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
"OK"
# BODY The text of a particular body section.
imap4d_test "FETCH 1:* BODY"\
"1 FETCH (BODY (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 972 35))"\
"2 FETCH (BODY (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 219 4))"\
"3 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"msg.1\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"How doth\" \"7BIT\" 239 9)(\"application\" \"octet-stream\" (\"name\" \"msg.21\") \"<5082.1026510189.2@example.net>\" \"Father William Part I\" \"base64\" 468) \"mixed\" NIL NIL NIL))"\
"4 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"msg.21\" \"charset\" \"us-ascii\") \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10)((\"application\" \"octet-stream\" (\"name\" \"msg.22\") \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486)((\"application\" \"octet-stream\" (\"name\" \"msg.23\") \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490)(\"application\" \"octet-stream\" (\"name\" \"msg.24\") \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502) \"mixed\" NIL NIL NIL) \"mixed\" NIL NIL NIL) \"mixed\" NIL NIL NIL))"\
"5 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"empty\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"Empty part\" \"7BIT\" 0 0)(\"text\" \"plain\" (\"name\" \"single.line\" \"charset\" \"us-ascii\") \"<5082.1026510189.2@example.net>\" \"Single line part\" \"7BIT\" 2 1) \"mixed\" NIL NIL NIL))"\
"OK"
# BODY.PEEK[<section>]<<partial>>
# An alternate form of BODY[<section>] that does not
# implicitly set the \Seen flag.
imap4d_test "FETCH 1 BODY.PEEK\[HEADER\]"\
"1 FETCH (BODY\[HEADER\] {326}"\
-literal\
"Received: (from foobar@nonexistent.net)"\
" by nonexistent.net id fBSKI8N04906"\
" for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
"From: Foo Bar <foobar@nonexistent.net>"\
"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
"To: Bar <bar@dontmailme.org>"\
"Subject: Jabberwocky"\
""\
")"\
"OK"
# The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT
# part specifiers refer to the [RFC-822] header of
# the message or of an encapsulated [MIME-IMT]
# MESSAGE/RFC822 message.
imap4d_test "FETCH 1 BODY\[HEADER\]"\
"1 FETCH (FLAGS (\\Seen) BODY\[HEADER\] {326}"\
-literal\
"Received: (from foobar@nonexistent.net)"\
" by nonexistent.net id fBSKI8N04906"\
" for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
"From: Foo Bar <foobar@nonexistent.net>"\
"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
"To: Bar <bar@dontmailme.org>"\
"Subject: Jabberwocky"\
""\
")"\
"OK"
# HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of
# field-name (as defined in [RFC-822]) names, and return a subset
# of the header.
# The subset returned by HEADER.FIELDS contains only those header fields
# with a field-name that matches one of the names in the list;
imap4d_test "FETCH 1 BODY\[HEADER.FIELDS (FROM TO SUBJECT)\]"\
"1 FETCH (BODY\[HEADER.FIELDS (FROM TO SUBJECT)\] {94}"\
-literal\
"FROM: Foo Bar <foobar@nonexistent.net>"\
"TO: Bar <bar@dontmailme.org>"\
"SUBJECT: Jabberwocky"\
""\
")"\
"OK"
# similarly, the subset returned by HEADER.FIELDS.NOT contains only
# the header fields with a non-matching field-name.
imap4d_test "FETCH 1 BODY\[HEADER.FIELDS.NOT (FROM TO SUBJECT)\]"\
"1 FETCH (BODY\[HEADER.FIELDS.NOT (FROM TO SUBJECT)\] {234}"\
-literal\
"Received: (from foobar@nonexistent.net)"\
" by nonexistent.net id fBSKI8N04906"\
" for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
""\
")"\
"OK"
# The TEXT part specifier refers to the text body of
# the message, omitting the [RFC-822] header.
imap4d_test "FETCH 1 BODY\[TEXT\]"\
"1 FETCH (BODY\[TEXT\] {972}"\
-literal\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
"`Beware the Jabberwock, my son!"\
"The jaws that bite, the claws that catch!"\
"Beware the Jujub bird, and shun"\
"The frumious Bandersnatch!'"\
""\
"He took his vorpal sword in hand:"\
"Long time the manxome foe he sought --"\
"So rested he by the Tumtum gree,"\
"And stood awhile in thought."\
""\
"And as in uffish thought he stood,"\
"The Jabberwock, with eyes of flame,"\
"Came whiffling through the tulgey wook,"\
"And burbled as it came!"\
""\
"One, two! One, two! And through and through"\
"The vorpal blade went snicker-snack!"\
"He left it dead, and with its head"\
"He went galumphing back."\
""\
"`And has thou slain the Jabberwock?"\
"Come to my arms, my beamish boy!"\
"O frabjous day! Calloh! Callay!"\
"He chortled in his joy."\
""\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
")"\
"OK"
# It is possible to fetch a substring of the
# designated text. This is done by appending an open
# angle bracket ("<"), the octet position of the
# first desired octet, a period, the maximum number
# of octets desired, and a close angle bracket (">")
# to the part specifier.
imap4d_test "FETCH 1 BODY\[TEXT\]<0.20>"\
"1 FETCH (BODY\[TEXT\]<0> {20}"\
-literal\
"`Twas brillig, and t)"\
"OK"
imap4d_test "FETCH 1 BODY\[TEXT\]<200.100>"\
"1 FETCH (BODY\[TEXT\]<200> {100}"\
-literal\
"t catch!"\
"Beware the Jujub bird, and shun"\
"The frumious Bandersnatch!'"\
""\
"He took his vorpal sword i)"\
"OK"
# If the starting octet is beyond the end of
# the text, an empty string is returned.
imap4d_test "FETCH 1 BODY\[TEXT\]<3900.4000>"\
"1 FETCH (BODY\[TEXT\]<3900> \"\")"\
"OK"
# Any partial fetch that attempts to read beyond the
# end of the text is truncated as appropriate. A
# partial fetch that starts at octet 0 is returned as
# a partial fetch, even if this truncation happened.
#
# Note: this means that BODY[]<0.2048> of a 1500-octet
# message will return BODY[]<0> with a literal of size 1500,
# not BODY[].
imap4d_test "FETCH 1 BODY\[TEXT\]<0.4000>"\
"1 FETCH (BODY\[TEXT\]<0> {972}"\
-literal\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
"`Beware the Jabberwock, my son!"\
"The jaws that bite, the claws that catch!"\
"Beware the Jujub bird, and shun"\
"The frumious Bandersnatch!'"\
""\
"He took his vorpal sword in hand:"\
"Long time the manxome foe he sought --"\
"So rested he by the Tumtum gree,"\
"And stood awhile in thought."\
""\
"And as in uffish thought he stood,"\
"The Jabberwock, with eyes of flame,"\
"Came whiffling through the tulgey wook,"\
"And burbled as it came!"\
""\
"One, two! One, two! And through and through"\
"The vorpal blade went snicker-snack!"\
"He left it dead, and with its head"\
"He went galumphing back."\
""\
"`And has thou slain the Jabberwock?"\
"Come to my arms, my beamish boy!"\
"O frabjous day! Calloh! Callay!"\
"He chortled in his joy."\
""\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
")"\
"OK"
# The MIME part specifier refers to the [MIME-IMB]
# header for this part.
# The MIME part specifier MUST be prefixed by one or
# more numeric part specifiers.
imap4d_test "FETCH 3 BODY\[1.MIME\]"\
"3 FETCH (FLAGS (\\Seen) BODY\[1.MIME\] {138}"\
-literal\
"Content-Type: text/plain; name=\"msg.1\"; charset=\"us-ascii\""\
"Content-ID: <5082.1026510189.1@example.net>"\
"Content-Description: How doth"\
""\
")"\
"OK"
imap4d_test "FETCH 4 BODY\[2.2.1\]"\
"4 FETCH (FLAGS (\\Seen) BODY\[2.2.1\] {490}"\
-literal\
"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh"\
"awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv"\
"b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn"\
"ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g"\
"dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1"\
"bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz"\
"dCBvZiBteSBsaWZlLicK"\
")"\
"OK"
###############
# Test RFC822 operations
# Clean \Seen flags
imap4d_test "STORE 1:* -FLAGS (\\Seen)"\
"1 FETCH (FLAGS (\\Recent))"\
"2 FETCH (FLAGS (\\Recent))"\
"3 FETCH (FLAGS (\\Recent))"\
"4 FETCH (FLAGS (\\Recent))"\
"5 FETCH (FLAGS (\\Recent))"\
"OK"
# RFC822 Functionally equivalent to BODY[], differing in the
# syntax of the resulting untagged FETCH data (RFC822
# is returned).
imap4d_test "FETCH 1 RFC822"\
"1 FETCH (FLAGS (\\Seen) RFC822 {1298}"\
-literal\
"Received: (from foobar@nonexistent.net)"\
" by nonexistent.net id fBSKI8N04906"\
" for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
"From: Foo Bar <foobar@nonexistent.net>"\
"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
"To: Bar <bar@dontmailme.org>"\
"Subject: Jabberwocky"\
""\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
"`Beware the Jabberwock, my son!"\
"The jaws that bite, the claws that catch!"\
"Beware the Jujub bird, and shun"\
"The frumious Bandersnatch!'"\
""\
"He took his vorpal sword in hand:"\
"Long time the manxome foe he sought --"\
"So rested he by the Tumtum gree,"\
"And stood awhile in thought."\
""\
"And as in uffish thought he stood,"\
"The Jabberwock, with eyes of flame,"\
"Came whiffling through the tulgey wook,"\
"And burbled as it came!"\
""\
"One, two! One, two! And through and through"\
"The vorpal blade went snicker-snack!"\
"He left it dead, and with its head"\
"He went galumphing back."\
""\
"`And has thou slain the Jabberwock?"\
"Come to my arms, my beamish boy!"\
"O frabjous day! Calloh! Callay!"\
"He chortled in his joy."\
""\
"`Twas brillig, and the slithy toves"\
"Did gyre and gimble in the wabe;"\
"All mimsy were the borogoves,"\
"And the mome raths outgrabe."\
""\
")"\
"OK"
# RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER],
# differing in the syntax of the resulting untagged
# FETCH data (RFC822.HEADER is returned).
imap4d_test "FETCH 2 RFC822.HEADER"\
"2 FETCH (RFC822.HEADER {328}"\
-literal\
"Received: (from bar@dontmailme.org)"\
" by dontmailme.org id fERKR9N16790"\
" for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200"\
"Date: Fri, 28 Dec 2001 23:28:08 +0200"\
"From: Bar <bar@dontmailme.org>"\
"To: Foo Bar <foobar@nonexistent.net>"\
"Message-Id: <200112232808.fERKR9N16790@dontmailme.org>"\
"Subject: Re: Jabberwocky"\
""\
")"\
"OK"
# RFC822.SIZE The [RFC-822] size of the message.
imap4d_test "FETCH 3 RFC822.SIZE"\
"3 FETCH (RFC822.SIZE 1611)"\
"OK"
# RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in
# the syntax of the resulting untagged FETCH data
# (RFC822.TEXT is returned).
imap4d_test "FETCH 2 RFC822.TEXT"\
"2 FETCH (FLAGS (\\Seen) RFC822.TEXT {219}"\
-literal\
"It seems very pretty, but it's *rather* hard to understand!'"\
"Somehow it seems to fill my head with ideas -- only I don't"\
"exactly know what they are! However, SOMEBODY killed SOMETHING:"\
"that's clear, at any rate..."\
")"\
"OK"
# FAST Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE)
imap4d_test "FETCH 1 FAST" \
-re {1 FETCH \(FLAGS \(\\Seen \\Recent\) INTERNALDATE \"28-Dec-2001 22:18:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1298\)}\
"OK"
# FULL Macro equivalent to: (FLAGS INTERNALDATE
# RFC822.SIZE ENVELOPE BODY)
imap4d_test "FETCH 4 FULL"\
-re {4 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:50:58 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 3483 ENVELOPE \(\"Sat, 13 Jul 2002 00:50:58 \+0300\" \"Nested MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"\) BODY \(\(\"text\" \"plain\" \(\"name\" \"msg.21\" \"charset\" \"us-ascii\"\) \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10\)\(\(\"application\" \"octet-stream\" \(\"name\" \"msg.22\"\) \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486\)\(\(\"application\" \"octet-stream\" \(\"name\" \"msg.23\"\) \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490\)\(\"application\" \"octet-stream\" \(\"name\" \"msg.24\"\) \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502\) \"mixed\" NIL NIL NIL\) \"mixed\" NIL NIL NIL\) \"mixed\" NIL NIL NIL\)\)}\
"OK"
imap4d_stop
# End of fetch.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
# Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test -sort "LIST \"~\" \"*\""\
"LIST (\\NoInferiors) \"/\" ~/mbox1"\
"LIST (\\NoInferiors) \"/\" ~/mbox"\
"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
"OK LIST Completed"
imap4d_test -sort "LIST \"~\" \"%\""\
"LIST (\\NoInferiors) \"/\" ~/mbox1"\
"LIST (\\NoInferiors) \"/\" ~/mbox"\
"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
"OK LIST Completed"
imap4d_test -sort "LIST \"\" \"*\""\
"LIST (\\NoInferiors) NIL INBOX"\
"LIST (\\NoInferiors) \"/\" mbox1"\
"LIST (\\NoInferiors) \"/\" mbox"\
"LIST (\\NoInferiors) \"/\" search.mbox"\
"LIST (\\NoInferiors) \"/\" sieve.mbox"\
"LIST (\\NoInferiors) \"/\" teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" bigto.mbox"\
"LIST (\\NoInferiors) \"/\" relational.mbox" \
"OK LIST Completed"
imap4d_test "LIST \"/\" \"*\""\
"NO LIST The requested item could not be found."
imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"*\""\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mail.rc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mailutils.rc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/passwd"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/relational.mbox" \
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox1"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/search.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/teaparty.mbox"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/two"\
"OK LIST Completed"
imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"%\""\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
"OK LIST Completed"
imap4d_test "LIST \"$MU_DATA_DIR/folder\" \"one\""\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
"OK LIST Completed"
imap4d_test -sort "LIST \"\" INBOX"\
"LIST (\\NoInferiors) NIL INBOX"\
"OK LIST Completed"
imap4d_stop
# End of list.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
# 6.4.4. SEARCH Command
# Arguments: OPTIONAL [CHARSET] specification
# searching criteria (one or more)
# Responses: REQUIRED untagged response: SEARCH
# Result: OK - search completed
# NO - search error: can't search that [CHARSET] or
# criteria
# BAD - command unknown or arguments invalid
#
# The SEARCH command searches the mailbox for messages that match
# the given searching criteria. Searching criteria consist of one
# or more search keys. The untagged SEARCH response from the server
# contains a listing of message sequence numbers corresponding to
# those messages that match the searching criteria.
imap4d_start -mbox "search.mbox"
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT INBOX"\
"8 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 9\] Predicted next uid"\
"OK \[UNSEEN 4\] first unseen messsage "\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
# <message set> Messages with message sequence numbers
# corresponding to the specified message sequence
# number set
imap4d_test "SEARCH 1:*" \
"SEARCH 1 2 3 4 5 6 7 8" \
"OK"
# ALL All messages in the mailbox; the default initial
# key for ANDing.
imap4d_test "SEARCH ALL" \
"SEARCH 1 2 3 4 5 6 7 8" \
"OK"
# NEW Messages that have the \Recent flag set but not the
# \Seen flag. This is functionally equivalent to
# "(RECENT UNSEEN)".
# All messages are still new
imap4d_test "SEARCH NEW" \
"SEARCH 4 5 6 7 8" \
"OK"
# FROM <string> Messages that contain the specified string in the
# envelope structure's FROM field.
imap4d_test "SEARCH FROM corrector" \
"SEARCH 2 4 8" \
"OK"
imap4d_test "SEARCH FROM lexi@example.net" \
"SEARCH 1 3 5 6 7" \
"OK"
# LARGER <n> Messages with an [RFC-822] size larger than the
# specified number of octets.
imap4d_test "SEARCH LARGER 512" \
"SEARCH 3 4" \
"OK"
# SMALLER <n> Messages with an [RFC-822] size smaller than the
# specified number of octets.
imap4d_test "SEARCH SMALLER 400" \
"SEARCH 7 8" \
"OK"
# SUBJECT <string> Messages that contain the specified string in the
# envelope structure's SUBJECT field.
imap4d_test "SEARCH SUBJECT \"Alliance\"" \
"SEARCH 6"\
"OK"
# HEADER <field-name> <string>
# Messages that have a header with the specified
# field-name (as defined in [RFC-822]) and that
# contains the specified string in the [RFC-822]
# field-body.
imap4d_test "SEARCH HEADER Message-Id \"<200207291200.3303@example.org>\"" \
"SEARCH 3" \
"OK"
# CC <string> Messages that contain the specified string in the
# envelope structure's CC field.
imap4d_test "SEARCH CC Corrector" \
"SEARCH 6" \
"OK"
# TO <string> Messages that contain the specified string in the
# envelope structure's TO field.
imap4d_test "SEARCH TO editor+recheck"\
"SEARCH 7" \
"OK"
# SENTBEFORE <date>
# Messages whose [RFC-822] Date: header is earlier
# than the specified date.
imap4d_test "SEARCH SENTBEFORE \"30-Jul-2002\"" \
"SEARCH 1 2"\
"OK"
# SENTSINCE <date>
# Messages whose [RFC-822] Date: header is within or
# later than the specified date.
imap4d_test "SEARCH SENTSINCE \"31-Jul-2002\""\
"SEARCH 5 6 7 8"\
"OK"
# BEFORE <date> Messages whose internal date is earlier than the
# specified date.
imap4d_test "SEARCH BEFORE \"30-Jul-2002\""\
"SEARCH 1"\
"OK"
# SINCE <date> Messages whose internal date is within or later
# than the specified date.
imap4d_test "SEARCH SINCE \"30-Jul-2002\""\
"SEARCH 2 3 4 5 6 7 8"\
"OK"
# ANSWERED Messages with the \Answered flag set.
imap4d_test "SEARCH ANSWERED"\
"SEARCH 2 3"\
"OK"
# TEXT <string> Messages that contain the specified string in the
# header or body of the message.
imap4d_test "SEARCH TEXT person"\
"SEARCH 2 5 8"\
"OK"
## Boolean operations
# When multiple keys are specified, the result is the intersection
# (AND function) of all the messages that match those keys.
imap4d_test "SEARCH TEXT person FROM corrector"\
"SEARCH 2"\
"OK"
imap4d_test "SEARCH SENTSINCE \"30-Jul-2002\" SENTBEFORE \"31-Jul-2002\"" \
"SEARCH 3 4" \
"OK"
# OR <search-key1> <search-key2>
# Messages that match either search key.
imap4d_test "SEARCH OR FROM corrector ANSWERED"\
"SEARCH 2 3 4 8" \
"OK"
## Check precedence
imap4d_test "SEARCH (OR FROM corrector ANSWERED) SENTSINCE \"30-Jul-2002\""\
"SEARCH 3 4 8" \
"OK"
imap4d_test "SEARCH OR FROM corrector ANSWERED SENTSINCE \"30-Jul-2002\""\
"SEARCH 3 4 8" \
"OK"
imap4d_test "SEARCH OR FROM corrector (ANSWERED SENTSINCE \"30-Jul-2002\")"\
"SEARCH 2 3 4 8" \
"OK"
imap4d_stop
# End of search.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
# Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
imap4d_start
imap4d_test -message "ID in initail state" "ID NIL"\
"BAD ID Wrong state"
imap4d_auth "user!passwd" "guessme"
imap4d_test -message "ID in auth state" "ID NIL"\
"OK"
imap4d_stop
# End of x.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
# Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
source $top_srcdir/testsuite/lib/mailutils.exp
mu_init "--rcfile=$objdir/imap4d.rc"
mu_version
if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
clone_output "WARNING: Support for virtual domains not compiled in"
clone_output "WARNING: Skipping tests for imap4d"
exit 0
}
set IMAP4D_ETC_DIR "$MU_DATA_DIR/etc"
mu_makespool "$MU_RC_DIR" "$IMAP4D_ETC_DIR"
mu_create_config imap4d
set IMAP4D_TAG 0
### Only procedures should come after this point.
proc imap4d_version {} {
global MU_TOOL
global MU_TOOL_FLAGS
global MU_TOOL_VERSION
mu_version
if ![is_remote host] {
clone_output "[which $MU_TOOL] version $MU_TOOL_VERSION"
} else {
clone_output "$MU_TOOL on remote host version $MU_TOOL_VERSION"
}
}
proc default_imap4d_start {args} {
global verbose
global MU_TOOL
global MU_TOOL_FLAGS
global expect_out
global imap4d_spawn_id
mu_version
set args [lindex $args 0]
if [info exists MU_TOOL_FLAGS] {
set sw "$MU_TOOL_FLAGS "
} else {
set sw ""
}
if [llength $args] {
append sw $args
}
set imap4d_cmd "$MU_TOOL $sw"
verbose "Spawning $imap4d_cmd"
set imap4d_spawn_id [remote_spawn host $imap4d_cmd]
if { $imap4d_spawn_id < 0 || $imap4d_spawn_id == "" } {
perror "Spawning $imap4d_cmd failed."
return 1;
}
mu_expect 360 {
-re "\\* (OK)|(PREAUTH) IMAP4rev1 Debugging mode.*\r\n" {
verbose "imap4d initialized."
}
default {
perror "imap4d not initialized"
exit 1
}
}
return 0
}
proc default_imap4d_stop {} {
verbose "Stopping imap4d"
if [imap4d_test "LOGOUT"\
"BYE Session terminating." \
"OK LOGOUT Completed"] {
perror "LOGOUT failed"
exit 1
}
remote_close host;
return 0
}
proc imap4d_start {args} {
global MU_SPOOL_DIR
verbose "Starting imap4d"
set reuse_spool 0
set mbox "teaparty.mbox"
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-reuse-spool"} {
set reuse_spool 1
} elseif {"$a" == "-mbox"} {
set mbox [lindex $args [expr $i + 1]]
incr i
} else {
break;
}
}
if {$reuse_spool == 0} {
mu_prepare_spools
mu_copy_file $MU_SPOOL_DIR/$mbox $MU_SPOOL_DIR/INBOX
}
return [default_imap4d_start [concat [lrange $args $i end]]]
}
proc imap4d_stop {} {
global imap4d_spawn_id
if {[info exists imap4d_spawn_id] && $imap4d_spawn_id > 0} {
default_imap4d_stop
unset imap4d_spawn_id
}
}
##
proc imap4d_make_command { string } {
global IMAP4D_TAG
incr IMAP4D_TAG
return "$IMAP4D_TAG $string"
}
proc imap4d_send { string } {
return [mu_send "$string"]
}
proc imap4d_command { cmd } {
return [mu_command [imap4d_make_command $cmd]]
}
proc imap4d_uidvalidity {} {
regsub "(\[0-9\]*)\[0-9\]" "[clock seconds]" "\\1\[0-9\]" val
return $val
}
proc imap4d_exit {} {
imap4d_stop
}
proc imap4d_auth {args} {
set user [lindex $args 0]
set pass [lindex $args 1]
if [imap4d_test "LOGIN $user $pass"] {
perror "Failed to authorize."
exit 1
}
}
# imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent][-sort]
# COMMAND [UNTAGGED...][TAGGED]
# COMMAND - Command to send.
# UNTAGGED - A list of untagged responses to expect in return.
# TAGGED - A tagged response to expect in return. Defaults to "OK"
# MESSAGE - [optional] message to output
proc imap4d_test {args} {
global IMAP4D_TAG
global verbose
set default ""
set message ""
set long 0
set silent 0
set sort 0
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-default"} {
set default [lindex $args [expr $i + 1]]
incr i
} elseif {"$a" == "-message"} {
set message [lindex $args [expr $i + 1]]
incr i
} elseif {"$a" == "-long"} {
set long 1
} elseif {"$a" == "-silent"} {
set silent 1
} elseif {"$a" == "-sort"} {
set sort 1
} else {
set args [lrange $args $i end]
break
}
}
if {"$message" == ""} {
set message [lindex $args 0]
}
if $verbose>2 then {
send_user "Message is \"$message\"\n"
}
set command [lindex $args 0]
if {$long} {
set command_data [lindex $args 1]
set args [lrange $args 1 end]
}
set pattern [list]
set len [expr [llength $args] - 1]
if {$len >= 2} {
set regexp 0
set literal 0
for {set i 1} {$i <= [expr $len - 1]} {incr i} {
switch -regexp -- "[lindex $args $i]" {
^-re.*$ -
^-- { set item "[lindex $args $i]"; set regexp 1 }
^-literal { set literal 1; continue }
^-noliteral { set literal 0; continue }
default { if {!$literal} {
if {$regexp} {
set item "\\* [lindex $args $i]"
} else {
set item "* [lindex $args $i]"
}
} else {
set item [lindex $args $i]
}
set regexp 0
}
}
set pattern [concat $pattern [list $item]]
}
set tagged [lindex $args end]
} elseif {$len == 1} {
set tagged [lindex $args end]
} else {
set tagged "OK"
}
verbose "TAGGED $tagged"
if {$long} {
set command "$command {[string length $command_data]}"
imap4d_command $command
set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
mu_expect 360 {
-re "^\\+ GO AHEAD.*$" { }
default {
perror "imap4d_long_test failed"
return 1
}
}
verbose "Sending $command_data" 3
mu_send "$command_data\n"
set s [split $command_data "\n"]
set s [lrange $s 0 [expr [llength $s] - 2]]
set result [mu_expect_list 360 [concat $s $pattern]]
} elseif {$sort && [llength $pattern] > 0} {
set command [imap4d_make_command $command]
set result [mu_test $command [list "-re" "(.*)\n$IMAP4D_TAG $tagged"]]
if {$result == 0} {
if [info exists expect_out(1,string)] {
set out [lsort -ascii [split $expect_out(1,string) "\n"]]
set in [lsort -ascii $pattern]
if {[llength $in] == [llength $out]} {
for {set i 0} {$i < [llength $in]} {incr i} {
regexp "(\[^\r\]*)" [lindex $out $i] dummy tmp
if [string compare [lindex $in $i] $tmp] {
verbose "Item $i comparison failed"
set result 1
break
}
}
} else {
verbose "Input and output lists have different lengths"
set result 1
}
if {$result} {
verbose "Input: $in"
verbose "Output: $out"
}
} else {
verbose "expect_out(1,string) does not exist. Buffer: $expect_out(buffer)"
set result 1
}
}
} else {
set command [imap4d_make_command $command]
set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
set result [mu_test $command $pattern]
}
if {!$silent} {
if {$result == 0} {
pass "$message"
} elseif {$result == 1} {
if { "$default" == "" || "$default" != "FAIL" } {
fail "$message"
} else {
xfail "$message"
set result 0
}
} elseif {$result == -2} {
fail "$message (timeout)"
} elseif {$result == -3} {
fail "$message (eof)"
} else {
fail "$message"
}
}
return $result
}