Commit 9370af7c 9370af7c2bbb53b7873ca6e26df058c84a0e487f by Sergey Poznyakoff

imap4d: rewrite testsuite in Autotest.

* configure.ac (IMAP_AUTHOBJS): Remove subst variable.  Use conditional
instead.
Configure imap4d/tests for testing.
Build imap4d/tests/Makefile and imap4d/tests/atlocal.
* imap4d/Makefile.am (SUBDIRS): Add tests.
[MU_COND_GSASL]: Define AUTH_GSASL
[MU_COND_GSSAPI]: Define AUTH_GSSAPI
(imap4d_SOURCES): Include AUTH_GSASL and AUTH_GSSAPI
(imap4d_LDADD,imap4d_DEPENDENCIES): Remove reference to IMAP_AUTHOBJS.
(EXTRA_DIST): Remove.

* imap4d/tests/.gitignore: New file.
* imap4d/tests/IDEF0955.at: New file
* imap4d/tests/IDEF0956.at: New file
* imap4d/tests/Makefile.am
* imap4d/tests/anystate.at: New file
* imap4d/tests/atlocal.in
* imap4d/tests/create01.at: New file
* imap4d/tests/create02.at: New file
* imap4d/tests/examine.at: New file
* imap4d/tests/expunge.at: New file
* imap4d/tests/id.at: New file
* imap4d/tests/list.at: New file
* imap4d/tests/search.at: New file
* imap4d/tests/select.at: New file
* imap4d/tests/status.at: New file
* imap4d/tests/testsuite.at: New file

* imap4d/fetch.c (fetch_io): Improve range checking.  If the requested
number of bytes is greater than maximum, truncate it.
* imap4d/imap4d.c: New option --test.
(test_mode): New global variable.
(imap4d_session_setup0): Fix improperly allocated automatic variable.
(main): Call GSASL and GSSAPI initializations only if mu_gsasl_enabled()
returns true.
* imap4d/imap4d.h (test_mode): New extern.
* imap4d/preauth.c: Do not complain about failed getpeername in test mode.
* imap4d/select.c: Fix human-readable response texts.

* include/mailutils/gsasl.h (mu_gsasl_module_data)<enable>: New member.
(mu_gsasl_enabled): New proto.
* libmailutils/mailbox/mailbox.c (mu_mailbox_flush):
(mu_mailbox_append_message,mu_mailbox_sync)
(mu_mailbox_expunge): Use MU_STREAM_WRITE instead of MU_STREAM_RDWR.
* libmu_auth/gsasl.c (mu_gsasl_module_data): Fix initialization.
(mu_gsasl_enabled): New function.
* libmu_cfg/gsasl.c (mu_gsasl_param): New parameter "enable".
1 parent 0d6303f8
...@@ -246,7 +246,6 @@ case "${withval}" in ...@@ -246,7 +246,6 @@ case "${withval}" in
246 *) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;; 246 *) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
247 esac],[usereadline=yes]) 247 esac],[usereadline=yes])
248 248
249 AC_SUBST(IMAP_AUTHOBJS)
250 AC_SUBST(SERV_AUTHLIBS) 249 AC_SUBST(SERV_AUTHLIBS)
251 AC_SUBST(SERV_AUTHINCS) 250 AC_SUBST(SERV_AUTHINCS)
252 251
...@@ -283,15 +282,14 @@ if test "x$status_gssapi" != "xno"; then ...@@ -283,15 +282,14 @@ if test "x$status_gssapi" != "xno"; then
283 esac 282 esac
284 done 283 done
285 SERV_AUTHINCS="$SERV_AUTHINCS $GSSAPI_CFLAGS" 284 SERV_AUTHINCS="$SERV_AUTHINCS $GSSAPI_CFLAGS"
286 IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gss.o"
287 AC_DEFINE(WITH_GSSAPI,1,[Define if mailutils is using GSSAPI]) 285 AC_DEFINE(WITH_GSSAPI,1,[Define if mailutils is using GSSAPI])
288 fi 286 fi
289 fi 287 fi
288 AM_CONDITIONAL([MU_COND_GSSAPI],[test "$status_gssapi" = "yes"])
290 289
291 MU_CHECK_GSASL(0.2.3, [ 290 MU_CHECK_GSASL(0.2.3, [
292 AC_DEFINE(WITH_GSASL,1,[Define if mailutils is using GNU SASL]) 291 AC_DEFINE(WITH_GSASL,1,[Define if mailutils is using GNU SASL])
293 MU_AUTHLIBS="$MU_AUTHLIBS $GSASL_LIBS" 292 MU_AUTHLIBS="$MU_AUTHLIBS $GSASL_LIBS"
294 IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gsasl.o"
295 status_gsasl=yes]) 293 status_gsasl=yes])
296 AM_CONDITIONAL([MU_COND_GSASL],[test "$status_gsasl" = "yes"]) 294 AM_CONDITIONAL([MU_COND_GSASL],[test "$status_gsasl" = "yes"])
297 295
...@@ -1304,6 +1302,7 @@ AC_CONFIG_TESTDIR(readmsg/tests) ...@@ -1304,6 +1302,7 @@ AC_CONFIG_TESTDIR(readmsg/tests)
1304 AC_CONFIG_TESTDIR(sieve/tests) 1302 AC_CONFIG_TESTDIR(sieve/tests)
1305 AC_CONFIG_TESTDIR(mh/tests) 1303 AC_CONFIG_TESTDIR(mh/tests)
1306 AC_CONFIG_TESTDIR(comsat/tests) 1304 AC_CONFIG_TESTDIR(comsat/tests)
1305 AC_CONFIG_TESTDIR(imap4d/tests)
1307 1306
1308 AC_CONFIG_FILES([libmailutils/tests/Makefile 1307 AC_CONFIG_FILES([libmailutils/tests/Makefile
1309 libmailutils/tests/atlocal 1308 libmailutils/tests/atlocal
...@@ -1315,6 +1314,8 @@ AC_CONFIG_FILES([libmailutils/tests/Makefile ...@@ -1315,6 +1314,8 @@ AC_CONFIG_FILES([libmailutils/tests/Makefile
1315 comsat/tests/atlocal 1314 comsat/tests/atlocal
1316 frm/tests/Makefile 1315 frm/tests/Makefile
1317 frm/tests/atlocal 1316 frm/tests/atlocal
1317 imap4d/tests/Makefile
1318 imap4d/tests/atlocal
1318 maidag/tests/Makefile 1319 maidag/tests/Makefile
1319 maidag/tests/atlocal 1320 maidag/tests/atlocal
1320 messages/tests/Makefile 1321 messages/tests/Makefile
......
...@@ -16,13 +16,22 @@ ...@@ -16,13 +16,22 @@
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17 17
18 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@ 18 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@
19 SUBDIRS = testsuite 19 SUBDIRS = tests testsuite
20 20
21 sbin_PROGRAMS = imap4d 21 sbin_PROGRAMS = imap4d
22 22
23 if MU_COND_GSASL
24 AUTH_GSASL = auth_gsasl.c
25 endif
26
27 if MU_COND_GSSAPI
28 AUTH_GSSAPI = auth_gss.c
29 endif
30
23 imap4d_SOURCES = \ 31 imap4d_SOURCES = \
24 append.c\ 32 append.c\
25 authenticate.c\ 33 authenticate.c\
34 $(AUTH_GSASL)\
26 bye.c\ 35 bye.c\
27 capability.c\ 36 capability.c\
28 check.c\ 37 check.c\
...@@ -62,7 +71,6 @@ imap4d_SOURCES = \ ...@@ -62,7 +71,6 @@ imap4d_SOURCES = \
62 util.c 71 util.c
63 72
64 imap4d_LDADD = \ 73 imap4d_LDADD = \
65 @IMAP_AUTHOBJS@\
66 ${MU_APP_LIBRARIES}\ 74 ${MU_APP_LIBRARIES}\
67 ${MU_LIB_MBOX}\ 75 ${MU_LIB_MBOX}\
68 ${MU_LIB_MH}\ 76 ${MU_LIB_MH}\
...@@ -72,16 +80,12 @@ imap4d_LDADD = \ ...@@ -72,16 +80,12 @@ imap4d_LDADD = \
72 ${MU_LIB_MAILUTILS}\ 80 ${MU_LIB_MAILUTILS}\
73 @SERV_AUTHLIBS@ @MU_COMMON_LIBRARIES@ @TCPWRAP_LIBRARIES@ 81 @SERV_AUTHLIBS@ @MU_COMMON_LIBRARIES@ @TCPWRAP_LIBRARIES@
74 82
75 ## This kludge is necessary to correctly establish imap4d -> IMAP_AUTHOBJS 83 ## This kludge is necessary to correctly establish imap4d -> MU_AUTHLIBS
76 ## and imap4d -> MU_AUTHLIBS dependencies. Automake stupidly refuses to 84 ## dependencies. Automake stupidly refuses to include them.
77 ## include them. 85 ## The same kludge appears in pop3d/Makefile.am and auth/Makefile.am
78 ## Same kludge appears in pop3d/Makefile.am and auth/Makefile.am
79 ## Think about better approach --gray 86 ## Think about better approach --gray
80 imap4d_DEPENDENCIES = \ 87 imap4d_DEPENDENCIES = \
81 @IMAP_AUTHOBJS@\
82 @MU_AUTHLIBS_DEPENDENCY@\ 88 @MU_AUTHLIBS_DEPENDENCY@\
83 ../lib/libmuaux.a\ 89 ../lib/libmuaux.a\
84 ${MU_LIB_MBOX}\ 90 ${MU_LIB_MBOX}\
85 ${MU_LIB_MAILUTILS} 91 ${MU_LIB_MAILUTILS}
86
87 EXTRA_DIST=auth_gss.c auth_gsasl.c
......
...@@ -784,17 +784,20 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max) ...@@ -784,17 +784,20 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
784 io_sendf ("<%lu>", (unsigned long) start); 784 io_sendf ("<%lu>", (unsigned long) start);
785 io_sendf (" \"\""); 785 io_sendf (" \"\"");
786 } 786 }
787 else if (size + 2 < size) /* Check for integer overflow */
788 {
789 mu_stream_destroy (&rfc);
790 return RESP_BAD;
791 }
792 else 787 else
793 { 788 {
794 int rc; 789 int rc;
795 char *buffer, *p; 790 char *buffer, *p;
796 size_t total = 0; 791 size_t total = 0;
797 792
793 if (size > max)
794 size = max;
795 if (size + 2 < size) /* Check for integer overflow */
796 {
797 mu_stream_destroy (&rfc);
798 return RESP_BAD;
799 }
800
798 p = buffer = malloc (size + 1); 801 p = buffer = malloc (size + 1);
799 if (!p) 802 if (!p)
800 imap4d_bye (ERR_NO_MEM); 803 imap4d_bye (ERR_NO_MEM);
......
...@@ -52,18 +52,22 @@ int ident_port; ...@@ -52,18 +52,22 @@ int ident_port;
52 char *ident_keyfile; 52 char *ident_keyfile;
53 int ident_encrypt_only; 53 int ident_encrypt_only;
54 54
55 int test_mode;
56
55 const char *program_version = "imap4d (" PACKAGE_STRING ")"; 57 const char *program_version = "imap4d (" PACKAGE_STRING ")";
56 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon."); 58 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon.");
57 59
58 #define OPT_PREAUTH 259 60 #define OPT_PREAUTH 259
59 #define OPT_FOREGROUND 260 61 #define OPT_FOREGROUND 260
62 #define OPT_TEST_MODE 261
60 63
61 static struct argp_option options[] = { 64 static struct argp_option options[] = {
62 { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0}, 65 { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0},
63 { "inetd", 'i', 0, 0, N_("run in inetd mode"), 0}, 66 { "inetd", 'i', 0, 0, N_("run in inetd mode"), 0},
64 { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL, 67 { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
65 N_("runs in daemon mode with a maximum of NUMBER children"), 0 }, 68 N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
66 69 { "test", OPT_TEST_MODE, 0, 0,
70 N_("run in test mode"), 0 },
67 { "preauth", OPT_PREAUTH, NULL, 0, 71 { "preauth", OPT_PREAUTH, NULL, 0,
68 N_("start in preauth mode") }, 72 N_("start in preauth mode") },
69 73
...@@ -119,6 +123,11 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state) ...@@ -119,6 +123,11 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
119 case OPT_PREAUTH: 123 case OPT_PREAUTH:
120 preauth_mode = preauth_stdio; 124 preauth_mode = preauth_stdio;
121 break; 125 break;
126
127 case OPT_TEST_MODE:
128 mu_argp_node_list_new (lst, "mode", "inetd");
129 test_mode = 1;
130 break;
122 131
123 case ARGP_KEY_INIT: 132 case ARGP_KEY_INIT:
124 mu_argp_node_list_init (&lst); 133 mu_argp_node_list_init (&lst);
...@@ -318,7 +327,7 @@ imap4d_session_setup0 () ...@@ -318,7 +327,7 @@ imap4d_session_setup0 ()
318 { 327 {
319 char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir); 328 char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir);
320 struct mu_wordsplit ws; 329 struct mu_wordsplit ws;
321 const char *env[3]; 330 const char *env[5];
322 331
323 env[0] = "user"; 332 env[0] = "user";
324 env[1] = auth_data->name; 333 env[1] = auth_data->name;
...@@ -414,9 +423,11 @@ imap4d_mainloop (int ifd, int ofd, int tls) ...@@ -414,9 +423,11 @@ imap4d_mainloop (int ifd, int ofd, int tls)
414 { 423 {
415 imap4d_tokbuf_t tokp; 424 imap4d_tokbuf_t tokp;
416 char *text; 425 char *text;
417 int debug_mode = isatty (ifd);
418 int signo; 426 int signo;
419 427
428 if (!test_mode)
429 test_mode = isatty (ifd);
430
420 if ((signo = setjmp (child_jmp))) 431 if ((signo = setjmp (child_jmp)))
421 { 432 {
422 mu_diag_output (MU_DIAG_CRIT, _("got signal `%s'"), strsignal (signo)); 433 mu_diag_output (MU_DIAG_CRIT, _("got signal `%s'"), strsignal (signo));
...@@ -453,10 +464,10 @@ imap4d_mainloop (int ifd, int ofd, int tls) ...@@ -453,10 +464,10 @@ imap4d_mainloop (int ifd, int ofd, int tls)
453 464
454 if (imap4d_preauth_setup (ifd) == 0) 465 if (imap4d_preauth_setup (ifd) == 0)
455 { 466 {
456 if (debug_mode) 467 if (test_mode)
457 { 468 {
458 mu_diag_output (MU_DIAG_INFO, _("started in debugging mode")); 469 mu_diag_output (MU_DIAG_INFO, _("started in test mode"));
459 text = "IMAP4rev1 Debugging mode"; 470 text = "IMAP4rev1 Test mode";
460 } 471 }
461 else 472 else
462 text = "IMAP4rev1"; 473 text = "IMAP4rev1";
...@@ -603,9 +614,12 @@ main (int argc, char **argv) ...@@ -603,9 +614,12 @@ main (int argc, char **argv)
603 #endif 614 #endif
604 615
605 namespace_init (); 616 namespace_init ();
606 617
607 auth_gssapi_init (); 618 if (mu_gsasl_enabled ())
608 auth_gsasl_init (); 619 {
620 auth_gssapi_init ();
621 auth_gsasl_init ();
622 }
609 623
610 #ifdef USE_LIBPAM 624 #ifdef USE_LIBPAM
611 if (!mu_pam_service) 625 if (!mu_pam_service)
......
...@@ -204,6 +204,8 @@ extern int imap4d_argc; ...@@ -204,6 +204,8 @@ extern int imap4d_argc;
204 extern char **imap4d_argv; 204 extern char **imap4d_argv;
205 extern jmp_buf child_jmp; 205 extern jmp_buf child_jmp;
206 206
207 extern int test_mode;
208
207 /* Input functions */ 209 /* Input functions */
208 extern mu_stream_t iostream; 210 extern mu_stream_t iostream;
209 extern int io_untagged_response (int, const char *, ...) MU_PRINTFLIKE(2,3); 211 extern int io_untagged_response (int, const char *, ...) MU_PRINTFLIKE(2,3);
......
...@@ -485,8 +485,13 @@ imap4d_preauth_setup (int fd) ...@@ -485,8 +485,13 @@ imap4d_preauth_setup (int fd)
485 } 485 }
486 else 486 else
487 psrv_sa = &srv_sa; 487 psrv_sa = &srv_sa;
488 488
489 if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1) 489 if (test_mode)
490 {
491 pclt_sa = NULL;
492 clt_len = 0;
493 }
494 else if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1)
490 { 495 {
491 mu_diag_output (MU_DIAG_ERROR, 496 mu_diag_output (MU_DIAG_ERROR,
492 _("cannot obtain IP address of client: %s"), 497 _("cannot obtain IP address of client: %s"),
......
...@@ -137,14 +137,14 @@ imap4d_select_status () ...@@ -137,14 +137,14 @@ imap4d_select_status ()
137 io_untagged_response (RESP_OK, "[UIDNEXT %lu] Predicted next uid", 137 io_untagged_response (RESP_OK, "[UIDNEXT %lu] Predicted next uid",
138 (unsigned long) uidnext); 138 (unsigned long) uidnext);
139 if (unseen) 139 if (unseen)
140 io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage ", 140 io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage",
141 (unsigned long) unseen); 141 (unsigned long) unseen);
142 io_untagged_response (RESP_NONE, "FLAGS (%s)", mflags); 142 io_untagged_response (RESP_NONE, "FLAGS (%s)", mflags);
143 /* FIXME: 143 /* FIXME:
144 - '\*' can be supported if we use the attribute_set userflag() 144 - '\*' can be supported if we use the attribute_set userflag()
145 - Answered is still not set in the mailbox code. */ 145 - Answered is still not set in the mailbox code. */
146 if (!(select_flags & MU_STREAM_WRITE)) 146 if (!(select_flags & MU_STREAM_WRITE))
147 io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No Permanent flags"); 147 io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No permanent flags");
148 else 148 else
149 io_untagged_response (RESP_OK, "[PERMANENTFLAGS (%s)] Permanent flags", 149 io_untagged_response (RESP_OK, "[PERMANENTFLAGS (%s)] Permanent flags",
150 mflags); 150 mflags);
......
1 atconfig
2 atlocal
3 package.m4
4 testsuite
5 testsuite.dir
6 testsuite.log
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([IDEF0955])
18
19 AT_CHECK([
20 limit=`expr $MU_ULONG_MAX - 1`
21
22 cat > input <<EOT
23 1 select INBOX
24 2 FETCH 1:$limit FLAGS
25 3 UID FETCH 1:$limit FLAGS
26 X LOGOUT
27 EOT
28
29 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox1,INBOX)
30
31 imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
32 ],
33 [0],
34 [* PREAUTH IMAP4rev1 Test mode
35 * 5 EXISTS
36 * 5 RECENT
37 * OK [[UIDNEXT 6]] Predicted next uid
38 * OK [[UNSEEN 1]] first unseen messsage
39 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
40 * OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
41 1 OK [[READ-WRITE]] SELECT Completed
42 2 OK FETCH Completed
43 * 1 FETCH (UID 1 FLAGS (\Recent))
44 * 2 FETCH (UID 2 FLAGS (\Recent))
45 * 3 FETCH (UID 3 FLAGS (\Recent))
46 * 4 FETCH (UID 4 FLAGS (\Recent))
47 * 5 FETCH (UID 5 FLAGS (\Recent))
48 3 OK UID FETCH Completed
49 * BYE Session terminating.
50 X OK LOGOUT Completed
51 ])
52
53 AT_CLEANUP
54
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([IDEF0956])
18
19 AT_CHECK([
20 limit=`expr $MU_ULONG_MAX - 1`
21
22 cat > input <<EOT
23 1 select INBOX
24 2 FETCH 1 BODY[[TEXT]]<0.$limit>
25 X LOGOUT
26 EOT
27
28 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
29
30 imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
31 ],
32 [0],
33 [* PREAUTH IMAP4rev1 Test mode
34 * 8 EXISTS
35 * 5 RECENT
36 * OK [[UIDNEXT 9]] Predicted next uid
37 * OK [[UNSEEN 4]] first unseen messsage
38 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
39 * OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
40 1 OK [[READ-WRITE]] SELECT Completed
41 * 1 FETCH (BODY[[TEXT]]<0> {161}
42 ABASEMENT, n. A decent and customary mental attitude in the presence
43 of wealth of power. Peculiarly appropriate in an employee when
44 addressing an employer.
45 )
46 2 OK FETCH Completed
47 * BYE Session terminating.
48 X OK LOGOUT Completed
49 ])
50
51 AT_CLEANUP
52
1 # This file is part of GNU Mailutils.
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg
18 DISTCLEANFILES = atconfig $(check_SCRIPTS)
19 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
20
21 ## ------------ ##
22 ## package.m4. ##
23 ## ------------ ##
24
25 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
26 $(AM_V_GEN){ \
27 echo '# Signature of the current package.'; \
28 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
29 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
30 echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
31 echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
32 echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
33 } >$(srcdir)/package.m4
34
35 #
36
37 ## ------------ ##
38 ## Test suite. ##
39 ## ------------ ##
40
41 TESTSUITE_AT = \
42 anystate.at\
43 create01.at\
44 create02.at\
45 examine.at\
46 expunge.at\
47 id.at\
48 IDEF0955.at\
49 IDEF0956.at\
50 list.at\
51 search.at\
52 select.at\
53 status.at\
54 testsuite.at
55
56 TESTSUITE = $(srcdir)/testsuite
57 M4=m4
58
59 AUTOTEST = $(AUTOM4TE) --language=autotest
60 $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
61 $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
62 $(AM_V_at)mv $@.tmp $@
63
64 atconfig: $(top_builddir)/config.status
65 cd $(top_builddir) && ./config.status tests/$@
66
67 clean-local:
68 @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
69
70 check-local: atconfig atlocal $(TESTSUITE)
71 @$(SHELL) $(TESTSUITE)
72
73 # Run the test suite on the *installed* tree.
74 #installcheck-local:
75 # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
76
77
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([Non-authenticated state])
18 AT_KEYWORDS([anystate])
19
20 m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
21
22 IMAP4D_CHECK([],
23 [1 CAPABILITY
24 2 NOOP
25 3 NAMESPACE
26 X LOGOUT
27 ],
28 [* OK IMAP4rev1 Test mode
29 * CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT
30 1 OK CAPABILITY Completed
31 2 OK NOOP Completed
32 3 BAD NAMESPACE Wrong state
33 * BYE Session terminating.
34 X OK LOGOUT Completed
35 ])
36
37 m4_popdef([IMAP4D_OPTIONS])
38
39 AT_CLEANUP
40
1 # @configure_input@ -*- shell-script -*-
2 # Configurable variable values for Mailutils test suite.
3 # Copyright (C) 2011 Free Software Foundation, Inc.
4
5 PATH=@abs_builddir@:@abs_top_builddir@/imap4d:$top_srcdir:$srcdir:$PATH
6 MU_ULONG_MAX=@MU_ULONG_MAX@
7
8 remove_untagged() {
9 sed '/^\*/d'
10 }
11
12 filter_untagged() {
13 sed 's/\(^\* \(OK\|BAD\|NO\|PREAUTH\)\).*/\1/'
14 }
15
16 remove_uidvalidity() {
17 sed '/^\* OK \[UIDVALIDITY/d'
18 }
19
20 remove_select_unagged() {
21 sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
22 }
23
24 sorted_list_output() {
25 sed '/^\* PREAUTH/d
26 /^\* OK/d
27 /^\* BYE/d
28 /^\* [0-9][0-9]* EXISTS/d
29 /^\* [0-9][0-9]* RECENT/d
30 /^\* FLAGS/d
31 /^[0-9X][0-9]* OK/d' | sort
32 }
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([create])
18 AT_KEYWORDS([create create00])
19
20 AT_CHECK([
21 AT_DATA([input],[dnl
22 1 create flat
23 X LOGOUT
24 ])
25
26 imap4d IMAP4D_OPTIONS < input | tr -d '\r'
27 find . -name flat
28 ],
29 [0],
30 [* PREAUTH IMAP4rev1 Test mode
31 1 OK CREATE Completed
32 * BYE Session terminating.
33 X OK LOGOUT Completed
34 ./flat
35 ])
36
37 AT_CLEANUP
38
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([create nested])
18 AT_KEYWORDS([create create01])
19
20 AT_CHECK([
21 AT_DATA([input],[dnl
22 1 create en/to/tre
23 X LOGOUT
24 ])
25
26 imap4d IMAP4D_OPTIONS < input | tr -d '\r'
27 find . -name tre
28 ],
29 [0],
30 [* PREAUTH IMAP4rev1 Test mode
31 1 OK CREATE Completed
32 * BYE Session terminating.
33 X OK LOGOUT Completed
34 ./en/to/tre
35 ])
36
37 AT_CLEANUP
38
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([examine])
18
19 IMAP4D_CHECK([
20 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
21 ],
22 [1 EXAMINE INBOX
23 X LOGOUT
24 ],
25 [* PREAUTH IMAP4rev1 Test mode
26 * 8 EXISTS
27 * 5 RECENT
28 * OK [[UIDNEXT 9]] Predicted next uid
29 * OK [[UNSEEN 4]] first unseen messsage
30 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
31 * OK [[PERMANENTFLAGS ()]] No permanent flags
32 1 OK [[READ-ONLY]] EXAMINE Completed
33 * BYE Session terminating.
34 X OK LOGOUT Completed
35 ])
36
37 AT_CLEANUP
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([expunge])
18
19 IMAP4D_CHECK([
20 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,temp)
21 sed 's/^\(Status: .*\)/\1D/' temp > INBOX
22 ],
23 [1 SELECT INBOX
24 2 EXPUNGE
25 X LOGOUT
26 ],
27 [* PREAUTH IMAP4rev1 Test mode
28 * 8 EXISTS
29 * 5 RECENT
30 * OK [[UIDNEXT 9]] Predicted next uid
31 * OK [[UNSEEN 4]] first unseen messsage
32 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
33 * OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
34 1 OK [[READ-WRITE]] SELECT Completed
35 * 1 EXPUNGED
36 * 1 EXPUNGED
37 * 1 EXPUNGED
38 * 5 EXISTS
39 * 5 RECENT
40 2 OK EXPUNGE Completed
41 * BYE Session terminating.
42 X OK LOGOUT Completed
43 ])
44
45 AT_CLEANUP
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([ID command])
18 AT_KEYWORDS([id])
19
20 m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
21
22 IMAP4D_CHECK([],
23 [1 ID NIL
24 X LOGOUT
25 ],
26 [* OK IMAP4rev1 Test mode
27 1 BAD ID Wrong state
28 * BYE Session terminating.
29 X OK LOGOUT Completed
30 ])
31
32 m4_popdef([IMAP4D_OPTIONS])
33
34 IMAP4D_CHECK([],
35 [1 ID NIL
36 X LOGOUT
37 ],
38 [* PREAUTH IMAP4rev1 Test mode
39 1 OK ID Completed
40 * BYE Session terminating.
41 X OK LOGOUT Completed
42 ])
43
44 AT_CLEANUP
45
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 m4_pushdef([IMAP4D_HOMEDIR],[spool])
18
19 dnl LIST_CHECK([NAME],[KW],[ARG],[OUTPUT],[EXTRA-CODE],[filter,][expand]
20 m4_define([LIST_CHECK],[
21 AT_SETUP([$1])
22 AT_KEYWORDS([list $2])
23
24 IMAP4D_CHECK([
25 mkdir IMAP4D_HOMEDIR
26 m4_foreach([MAILBOX],[bigto.mbox,mbox1,mbox,relational.mbox,relational.mbox,
27 search.mbox,sieve.mbox,teaparty.mbox],[
28 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/MAILBOX,IMAP4D_HOMEDIR)
29 ])
30 $5
31 ],
32 [1 LIST $3
33 X LOGOUT
34 ],
35 [$4],
36 [],
37 [sorted_list_output[]m4_if([$6],,,|[$6])],[$7])
38 AT_CLEANUP
39 ])
40
41 dnl ----------------------------------------------------------------------
42 LIST_CHECK([asterisk],[list00],
43 ["~" "*"],
44 [dnl
45 * LIST (\NoInferiors) "/" ~/bigto.mbox
46 * LIST (\NoInferiors) "/" ~/mbox
47 * LIST (\NoInferiors) "/" ~/mbox1
48 * LIST (\NoInferiors) "/" ~/relational.mbox
49 * LIST (\NoInferiors) "/" ~/search.mbox
50 * LIST (\NoInferiors) "/" ~/sieve.mbox
51 * LIST (\NoInferiors) "/" ~/teaparty.mbox
52 ])
53
54 LIST_CHECK([percent],[list01],
55 ["~" "%"],
56 [dnl
57 * LIST (\NoInferiors) "/" ~/bigto.mbox
58 * LIST (\NoInferiors) "/" ~/mbox
59 * LIST (\NoInferiors) "/" ~/mbox1
60 * LIST (\NoInferiors) "/" ~/relational.mbox
61 * LIST (\NoInferiors) "/" ~/search.mbox
62 * LIST (\NoInferiors) "/" ~/sieve.mbox
63 * LIST (\NoInferiors) "/" ~/teaparty.mbox
64 ])
65
66 LIST_CHECK([empty ref + asterisk],[list02],
67 ["" "*"],
68 [dnl
69 * LIST (\NoInferiors) "/" bigto.mbox
70 * LIST (\NoInferiors) "/" mbox
71 * LIST (\NoInferiors) "/" mbox1
72 * LIST (\NoInferiors) "/" relational.mbox
73 * LIST (\NoInferiors) "/" search.mbox
74 * LIST (\NoInferiors) "/" sieve.mbox
75 * LIST (\NoInferiors) "/" teaparty.mbox
76 * LIST (\NoInferiors) NIL INBOX
77 ])
78
79 LIST_CHECK([root ref + asterisk],[list03],
80 ["/" "*"],
81 [dnl
82 1 NO LIST The requested item could not be found.
83 ])
84
85 LIST_CHECK([absolute reference + asterisk],[list04],
86 ["$cwd/spool" "*"],
87 [dnl
88 * LIST (\NoInferiors) "/" ////bigto.mbox
89 * LIST (\NoInferiors) "/" ////folder/one
90 * LIST (\NoInferiors) "/" ////folder/two
91 * LIST (\NoInferiors) "/" ////mbox
92 * LIST (\NoInferiors) "/" ////mbox1
93 * LIST (\NoInferiors) "/" ////relational.mbox
94 * LIST (\NoInferiors) "/" ////search.mbox
95 * LIST (\NoInferiors) "/" ////sieve.mbox
96 * LIST (\NoInferiors) "/" ////teaparty.mbox
97 * LIST (\NoSelect) "/" ////folder
98 ],
99 [mkdir IMAP4D_HOMEDIR/folder
100 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
101 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
102 [sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
103 [expand])
104
105 LIST_CHECK([absolute reference + percent],[list05],
106 ["$cwd/spool" "%"],
107 [dnl
108 * LIST (\NoInferiors) "/" ////bigto.mbox
109 * LIST (\NoInferiors) "/" ////mbox
110 * LIST (\NoInferiors) "/" ////mbox1
111 * LIST (\NoInferiors) "/" ////relational.mbox
112 * LIST (\NoInferiors) "/" ////search.mbox
113 * LIST (\NoInferiors) "/" ////sieve.mbox
114 * LIST (\NoInferiors) "/" ////teaparty.mbox
115 * LIST (\NoSelect) "/" ////folder
116 ],
117 [mkdir IMAP4D_HOMEDIR/folder
118 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
119 MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
120 [sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
121 [expand])
122
123 LIST_CHECK([absolute reference + mailbox],[list06],
124 ["$cwd/spool" "search.mbox"],
125 [dnl
126 * LIST (\NoInferiors) "/" ////search.mbox
127 ],
128 [],
129 [sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
130 [expand])
131
132 LIST_CHECK([empty reference + INBOX],[list07],
133 ["" INBOX],
134 [dnl
135 * LIST (\NoInferiors) NIL INBOX
136 ])
137
138 dnl ----------------------------------------------------------------------
139
140 m4_popdef([IMAP4D_HOMEDIR])
141
142
143
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 dnl SEARCH_CHECK([NAME],[KW],[ARG],[OUTPUT])
18 m4_define([SEARCH_CHECK],[
19 AT_SETUP([$1])
20 AT_KEYWORDS([search $2])
21 IMAP4D_CHECK([
22 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
23 ],
24 [1 SELECT INBOX
25 2 SEARCH $3
26 X LOGOUT
27 ],
28 [* PREAUTH IMAP4rev1 Test mode
29 * SEARCH $4
30 2 OK SEARCH Completed
31 * BYE Session terminating.
32 X OK LOGOUT Completed
33 ],
34 [],
35 [remove_select_unagged])
36
37 AT_CLEANUP
38 ])
39
40 dnl ----------------------------------------------------------------------
41 # <message set> Messages with message sequence numbers
42 # corresponding to the specified message sequence
43 # number set
44 SEARCH_CHECK([search sequence number],[search00],
45 [1:*],[1 2 3 4 5 6 7 8])
46
47 # ALL All messages in the mailbox; the default initial
48 # key for ANDing.
49 SEARCH_CHECK([search all],[search01],
50 [ALL],[1 2 3 4 5 6 7 8])
51
52 # NEW Messages that have the \Recent flag set but not the
53 # \Seen flag. This is functionally equivalent to
54 # "(RECENT UNSEEN)".
55 SEARCH_CHECK([search new],[search02],
56 [NEW],[4 5 6 7 8])
57
58 # FROM <string> Messages that contain the specified string in the
59 # envelope structure's FROM field.
60 SEARCH_CHECK([search from personal],[search03],
61 [FROM corrector],[2 4 8])
62
63 SEARCH_CHECK([search from email],[search04],
64 [FROM lexi@example.net],[1 3 5 6 7])
65
66 # LARGER <n> Messages with an [RFC-822] size larger than the
67 # specified number of octets.
68 SEARCH_CHECK([search larger],[search05],
69 [LARGER 512],[3 4])
70
71 # SMALLER <n> Messages with an [RFC-822] size smaller than the
72 # specified number of octets.
73 SEARCH_CHECK([search smaller],[search06],
74 [SMALLER 400],[7 8])
75
76 # SUBJECT <string> Messages that contain the specified string in the
77 # envelope structure's SUBJECT field.
78 SEARCH_CHECK([search subject],[search07],
79 [SUBJECT "Alliance"],[6])
80
81 # HEADER <field-name> <string>
82 # Messages that have a header with the specified
83 # field-name (as defined in [RFC-822]) and that
84 # contains the specified string in the [RFC-822]
85 # field-body.
86 SEARCH_CHECK([search header],[search08],
87 [HEADER Message-Id "<200207291200.3303@example.org>"],[3])
88
89 # CC <string> Messages that contain the specified string in the
90 # envelope structure's CC field.
91 SEARCH_CHECK([search cc],[search09],
92 [CC Corrector],[6])
93
94 # TO <string> Messages that contain the specified string in the
95 # envelope structure's TO field.
96 SEARCH_CHECK([search to],[search10],
97 [TO editor+recheck],[7])
98
99 # SENTBEFORE <date>
100 # Messages whose [RFC-822] Date: header is earlier
101 # than the specified date.
102 SEARCH_CHECK([search sentbefore],[search11],
103 [SENTBEFORE "30-Jul-2002"],[1 2])
104
105 # SENTSINCE <date>
106 # Messages whose [RFC-822] Date: header is within or
107 # later than the specified date.
108 SEARCH_CHECK([search sentsince],[search12],
109 [SENTSINCE "31-Jul-2002"],[5 6 7 8])
110
111 # BEFORE <date> Messages whose internal date is earlier than the
112 # specified date.
113 SEARCH_CHECK([search beforedate],[search13],
114 [BEFORE "30-Jul-2002"],[1])
115
116 # SINCE <date> Messages whose internal date is within or later
117 # than the specified date.
118 SEARCH_CHECK([search since],[search14],
119 [SINCE "30-Jul-2002"],[2 3 4 5 6 7 8])
120
121 # ANSWERED Messages with the \Answered flag set.
122 SEARCH_CHECK([search answered],[search15],
123 [ANSWERED],[2 3])
124
125 # TEXT <string> Messages that contain the specified string in the
126 # header or body of the message.
127 SEARCH_CHECK([search text],[search16],
128 [TEXT person],[2 5 8])
129
130 # When multiple keys are specified, the result is the intersection
131 # (AND function) of all the messages that match those keys.
132 SEARCH_CHECK([search multiple keys (implicit AND) 1],[search17],
133 [TEXT person FROM corrector],[2 8])
134
135 SEARCH_CHECK([search multiple keys (implicit AND) 2],[search18],
136 [SENTSINCE "30-Jul-2002" SENTBEFORE "31-Jul-2002"],[3 4])
137
138 # OR <search-key1> <search-key2>
139 # Messages that match either search key.
140 SEARCH_CHECK([search or],[search19],
141 [OR FROM corrector ANSWERED],[2 3 4 8])
142
143 # Test precedence
144 SEARCH_CHECK([precedence 1],[search20],
145 [(OR FROM corrector ANSWERED) SENTSINCE "30-Jul-2002"],[3 4 8])
146
147 SEARCH_CHECK([precedence 2],[search21],
148 [OR FROM corrector ANSWERED SENTSINCE "30-Jul-2002"],[3 4 8])
149
150 SEARCH_CHECK([precedence 3],[search22],
151 [OR FROM corrector (ANSWERED SENTSINCE "30-Jul-2002")],[2 3 4 8])
152
153 dnl ----------------------------------------------------------------------
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([select])
18
19 IMAP4D_CHECK([
20 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
21 ],
22 [1 SELECT INBOX
23 X LOGOUT
24 ],
25 [* PREAUTH IMAP4rev1 Test mode
26 * 8 EXISTS
27 * 5 RECENT
28 * OK [[UIDNEXT 9]] Predicted next uid
29 * OK [[UNSEEN 4]] first unseen messsage
30 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
31 * OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
32 1 OK [[READ-WRITE]] SELECT Completed
33 * BYE Session terminating.
34 X OK LOGOUT Completed
35 ])
36
37 AT_CLEANUP
38
39
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([status])
18
19 IMAP4D_CHECK([
20 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
21 ],
22 [1 STATUS INBOX (MESSAGES RECENT UNSEEN UIDNEXT)
23 X LOGOUT
24 ],
25 [* PREAUTH IMAP4rev1 Test mode
26 * STATUS INBOX (MESSAGES 8 RECENT 5 UNSEEN 5 UIDNEXT 9)
27 1 OK STATUS Completed
28 * BYE Session terminating.
29 X OK LOGOUT Completed
30 ])
31
32 AT_CLEANUP
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 m4_include([testsuite.inc])
18
19 m4_define([IMAP4D_HOMEDIR])
20
21 m4_define([IMAP4D_DEFAULT_OPTIONS],[dnl
22 --no-site-config dnl
23 --no-user-config dnl
24 --test dnl
25 --set logging.syslog=0 dnl
26 --set logging.severity=notice dnl
27 --set .gsasl.enable=0 dnl
28 --set '|homedir='`pwd`m4_if([IMAP4D_HOMEDIR],,,/[IMAP4D_HOMEDIR]) dnl
29 --set '|mailbox|folder='`pwd` dnl
30 --set '|mailbox|mailbox-pattern='`pwd`/INBOX dnl
31 ])
32
33 m4_define([IMAP4D_PREAUTH_OPTIONS],[dnl
34 IMAP4D_DEFAULT_OPTIONS dnl
35 --preauth dnl
36 ])
37
38 m4_define([IMAP4D_OPTIONS],[IMAP4D_PREAUTH_OPTIONS])
39
40 dnl ------------------------------------------------------------
41 dnl IMAP4D_CHECK([PREP], [INPUT], [STDOUT = `'], [STDERR = `'],
42 dnl [FILTER = `'],[expand])
43 dnl
44 m4_pushdef([IMAP4D_CHECK],[
45 cwd=`pwd`
46 m4_if([$6],,[dnl
47 AT_DATA([input],[$2])dnl
48 ],[cat > input <<EOT
49 [$2]
50 EOT
51 ])
52 $1
53 AT_CHECK([
54 imap4d IMAP4D_OPTIONS < input | tr -d '\r' | dnl
55 m4_if([$5],,[remove_uidvalidity],[$5])
56 ],
57 [0],
58 [$3],
59 [$4])
60 ])
61
62 AT_INIT
63 AT_TESTED([imap4d])
64 MUT_VERSION(imap4d)
65
66 m4_include([anystate.at])
67 m4_include([id.at])
68
69 m4_include([select.at])
70 m4_include([examine.at])
71 m4_include([status.at])
72 m4_include([expunge.at])
73 m4_include([create01.at])
74 m4_include([create02.at])
75
76 AT_BANNER([LIST])
77 m4_include([list.at])
78
79 AT_BANNER([SEARCH])
80 m4_include([search.at])
81
82 AT_BANNER([IDEF Checks])
83 m4_include([IDEF0955.at])
84 m4_include([IDEF0956.at])
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
21 21
22 struct mu_gsasl_module_data 22 struct mu_gsasl_module_data
23 { 23 {
24 int enable;
24 char *service; 25 char *service;
25 char *realm; 26 char *realm;
26 char *hostname; 27 char *hostname;
...@@ -28,13 +29,15 @@ struct mu_gsasl_module_data ...@@ -28,13 +29,15 @@ struct mu_gsasl_module_data
28 char *cram_md5_pwd; 29 char *cram_md5_pwd;
29 }; 30 };
30 31
31 int mu_gsasl_module_init (enum mu_gocs_op, void *); 32 int mu_gsasl_enabled (void);
32
33 extern struct mu_gsasl_module_data mu_gsasl_module_data;
34 33
35 #ifdef WITH_GSASL 34 #ifdef WITH_GSASL
36 #include <gsasl.h> 35 #include <gsasl.h>
37 36
37 int mu_gsasl_module_init (enum mu_gocs_op, void *);
38 extern struct mu_gsasl_module_data mu_gsasl_module_data;
39
40
38 int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport, 41 int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport,
39 Gsasl_session *ctx, int flags); 42 Gsasl_session *ctx, int flags);
40 int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport, 43 int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport,
......
...@@ -330,7 +330,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge) ...@@ -330,7 +330,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge)
330 return MU_ERR_MBX_REMOVED; 330 return MU_ERR_MBX_REMOVED;
331 if (!(mbox->flags & _MU_MAILBOX_OPEN)) 331 if (!(mbox->flags & _MU_MAILBOX_OPEN))
332 return _MU_MAILBOX_OPEN; 332 return _MU_MAILBOX_OPEN;
333 if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND))) 333 if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
334 return 0; 334 return 0;
335 335
336 mu_mailbox_messages_count (mbox, &total); 336 mu_mailbox_messages_count (mbox, &total);
...@@ -375,7 +375,7 @@ int ...@@ -375,7 +375,7 @@ int
375 mu_mailbox_append_message (mu_mailbox_t mbox, mu_message_t msg) 375 mu_mailbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
376 { 376 {
377 _MBOX_CHECK_Q (mbox, _append_message); 377 _MBOX_CHECK_Q (mbox, _append_message);
378 if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND))) 378 if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
379 return EACCES; 379 return EACCES;
380 return mbox->_append_message (mbox, msg); 380 return mbox->_append_message (mbox, msg);
381 } 381 }
...@@ -422,7 +422,7 @@ int ...@@ -422,7 +422,7 @@ int
422 mu_mailbox_sync (mu_mailbox_t mbox) 422 mu_mailbox_sync (mu_mailbox_t mbox)
423 { 423 {
424 _MBOX_CHECK_Q (mbox, _sync); 424 _MBOX_CHECK_Q (mbox, _sync);
425 if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND))) 425 if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
426 return 0; 426 return 0;
427 return mbox->_sync (mbox); 427 return mbox->_sync (mbox);
428 } 428 }
...@@ -438,7 +438,7 @@ int ...@@ -438,7 +438,7 @@ int
438 mu_mailbox_expunge (mu_mailbox_t mbox) 438 mu_mailbox_expunge (mu_mailbox_t mbox)
439 { 439 {
440 _MBOX_CHECK_Q (mbox, _expunge); 440 _MBOX_CHECK_Q (mbox, _expunge);
441 if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND))) 441 if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
442 return EACCES; 442 return EACCES;
443 return mbox->_expunge (mbox); 443 return mbox->_expunge (mbox);
444 } 444 }
......
...@@ -38,7 +38,12 @@ ...@@ -38,7 +38,12 @@
38 #include <gsasl.h> 38 #include <gsasl.h>
39 39
40 struct mu_gsasl_module_data mu_gsasl_module_data = { 40 struct mu_gsasl_module_data mu_gsasl_module_data = {
41 SITE_CRAM_MD5_PWD 41 1,
42 NULL,
43 NULL,
44 NULL,
45 NULL,
46 SITE_CRAM_MD5_PWD
42 }; 47 };
43 48
44 int 49 int
...@@ -49,6 +54,12 @@ mu_gsasl_module_init (enum mu_gocs_op op, void *data) ...@@ -49,6 +54,12 @@ mu_gsasl_module_init (enum mu_gocs_op op, void *data)
49 return 0; 54 return 0;
50 } 55 }
51 56
57 int
58 mu_gsasl_enabled (void)
59 {
60 return mu_gsasl_module_data.enable;
61 }
62
52 63
53 static enum mu_filter_result 64 static enum mu_filter_result
54 _gsasl_encoder (void *xdata, 65 _gsasl_encoder (void *xdata,
...@@ -214,5 +225,10 @@ mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport, ...@@ -214,5 +225,10 @@ mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport,
214 mu_stream_unref (out); 225 mu_stream_unref (out);
215 return rc; 226 return rc;
216 } 227 }
217 228 #else
229 int
230 mu_gsasl_enabled (void)
231 {
232 return 0;
233 }
218 #endif 234 #endif
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
25 static struct mu_gsasl_module_data gsasl_settings; 25 static struct mu_gsasl_module_data gsasl_settings;
26 26
27 static struct mu_cfg_param mu_gsasl_param[] = { 27 static struct mu_cfg_param mu_gsasl_param[] = {
28 { "enable", mu_cfg_bool, &gsasl_settings.enable, 0, NULL,
29 N_("Enable GSASL (default)") },
28 { "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd, 0, NULL, 30 { "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
29 N_("Name of GSASL password file."), 31 N_("Name of GSASL password file."),
30 N_("file") }, 32 N_("file") },
......