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
*) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
esac],[usereadline=yes])
AC_SUBST(IMAP_AUTHOBJS)
AC_SUBST(SERV_AUTHLIBS)
AC_SUBST(SERV_AUTHINCS)
......@@ -283,15 +282,14 @@ if test "x$status_gssapi" != "xno"; then
esac
done
SERV_AUTHINCS="$SERV_AUTHINCS $GSSAPI_CFLAGS"
IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gss.o"
AC_DEFINE(WITH_GSSAPI,1,[Define if mailutils is using GSSAPI])
fi
fi
AM_CONDITIONAL([MU_COND_GSSAPI],[test "$status_gssapi" = "yes"])
MU_CHECK_GSASL(0.2.3, [
AC_DEFINE(WITH_GSASL,1,[Define if mailutils is using GNU SASL])
MU_AUTHLIBS="$MU_AUTHLIBS $GSASL_LIBS"
IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gsasl.o"
status_gsasl=yes])
AM_CONDITIONAL([MU_COND_GSASL],[test "$status_gsasl" = "yes"])
......@@ -1304,6 +1302,7 @@ AC_CONFIG_TESTDIR(readmsg/tests)
AC_CONFIG_TESTDIR(sieve/tests)
AC_CONFIG_TESTDIR(mh/tests)
AC_CONFIG_TESTDIR(comsat/tests)
AC_CONFIG_TESTDIR(imap4d/tests)
AC_CONFIG_FILES([libmailutils/tests/Makefile
libmailutils/tests/atlocal
......@@ -1315,6 +1314,8 @@ AC_CONFIG_FILES([libmailutils/tests/Makefile
comsat/tests/atlocal
frm/tests/Makefile
frm/tests/atlocal
imap4d/tests/Makefile
imap4d/tests/atlocal
maidag/tests/Makefile
maidag/tests/atlocal
messages/tests/Makefile
......
......@@ -16,13 +16,22 @@
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@
SUBDIRS = testsuite
SUBDIRS = tests testsuite
sbin_PROGRAMS = imap4d
if MU_COND_GSASL
AUTH_GSASL = auth_gsasl.c
endif
if MU_COND_GSSAPI
AUTH_GSSAPI = auth_gss.c
endif
imap4d_SOURCES = \
append.c\
authenticate.c\
$(AUTH_GSASL)\
bye.c\
capability.c\
check.c\
......@@ -62,7 +71,6 @@ imap4d_SOURCES = \
util.c
imap4d_LDADD = \
@IMAP_AUTHOBJS@\
${MU_APP_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_MH}\
......@@ -72,16 +80,12 @@ imap4d_LDADD = \
${MU_LIB_MAILUTILS}\
@SERV_AUTHLIBS@ @MU_COMMON_LIBRARIES@ @TCPWRAP_LIBRARIES@
## This kludge is necessary to correctly establish imap4d -> IMAP_AUTHOBJS
## and imap4d -> MU_AUTHLIBS dependencies. Automake stupidly refuses to
## include them.
## Same kludge appears in pop3d/Makefile.am and auth/Makefile.am
## This kludge is necessary to correctly establish imap4d -> MU_AUTHLIBS
## dependencies. Automake stupidly refuses to include them.
## The same kludge appears in pop3d/Makefile.am and auth/Makefile.am
## Think about better approach --gray
imap4d_DEPENDENCIES = \
@IMAP_AUTHOBJS@\
@MU_AUTHLIBS_DEPENDENCY@\
../lib/libmuaux.a\
${MU_LIB_MBOX}\
${MU_LIB_MAILUTILS}
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)
io_sendf ("<%lu>", (unsigned long) start);
io_sendf (" \"\"");
}
else if (size + 2 < size) /* Check for integer overflow */
{
mu_stream_destroy (&rfc);
return RESP_BAD;
}
else
{
int rc;
char *buffer, *p;
size_t total = 0;
if (size > max)
size = max;
if (size + 2 < size) /* Check for integer overflow */
{
mu_stream_destroy (&rfc);
return RESP_BAD;
}
p = buffer = malloc (size + 1);
if (!p)
imap4d_bye (ERR_NO_MEM);
......
......@@ -52,18 +52,22 @@ int ident_port;
char *ident_keyfile;
int ident_encrypt_only;
int test_mode;
const char *program_version = "imap4d (" PACKAGE_STRING ")";
static char doc[] = N_("GNU imap4d -- the IMAP4D daemon.");
#define OPT_PREAUTH 259
#define OPT_FOREGROUND 260
#define OPT_TEST_MODE 261
static struct argp_option options[] = {
{ "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0},
{ "inetd", 'i', 0, 0, N_("run in inetd mode"), 0},
{ "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
{ "test", OPT_TEST_MODE, 0, 0,
N_("run in test mode"), 0 },
{ "preauth", OPT_PREAUTH, NULL, 0,
N_("start in preauth mode") },
......@@ -119,6 +123,11 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
case OPT_PREAUTH:
preauth_mode = preauth_stdio;
break;
case OPT_TEST_MODE:
mu_argp_node_list_new (lst, "mode", "inetd");
test_mode = 1;
break;
case ARGP_KEY_INIT:
mu_argp_node_list_init (&lst);
......@@ -318,7 +327,7 @@ imap4d_session_setup0 ()
{
char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir);
struct mu_wordsplit ws;
const char *env[3];
const char *env[5];
env[0] = "user";
env[1] = auth_data->name;
......@@ -414,9 +423,11 @@ imap4d_mainloop (int ifd, int ofd, int tls)
{
imap4d_tokbuf_t tokp;
char *text;
int debug_mode = isatty (ifd);
int signo;
if (!test_mode)
test_mode = isatty (ifd);
if ((signo = setjmp (child_jmp)))
{
mu_diag_output (MU_DIAG_CRIT, _("got signal `%s'"), strsignal (signo));
......@@ -453,10 +464,10 @@ imap4d_mainloop (int ifd, int ofd, int tls)
if (imap4d_preauth_setup (ifd) == 0)
{
if (debug_mode)
if (test_mode)
{
mu_diag_output (MU_DIAG_INFO, _("started in debugging mode"));
text = "IMAP4rev1 Debugging mode";
mu_diag_output (MU_DIAG_INFO, _("started in test mode"));
text = "IMAP4rev1 Test mode";
}
else
text = "IMAP4rev1";
......@@ -603,9 +614,12 @@ main (int argc, char **argv)
#endif
namespace_init ();
auth_gssapi_init ();
auth_gsasl_init ();
if (mu_gsasl_enabled ())
{
auth_gssapi_init ();
auth_gsasl_init ();
}
#ifdef USE_LIBPAM
if (!mu_pam_service)
......
......@@ -204,6 +204,8 @@ extern int imap4d_argc;
extern char **imap4d_argv;
extern jmp_buf child_jmp;
extern int test_mode;
/* Input functions */
extern mu_stream_t iostream;
extern int io_untagged_response (int, const char *, ...) MU_PRINTFLIKE(2,3);
......
......@@ -485,8 +485,13 @@ imap4d_preauth_setup (int fd)
}
else
psrv_sa = &srv_sa;
if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1)
if (test_mode)
{
pclt_sa = NULL;
clt_len = 0;
}
else if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1)
{
mu_diag_output (MU_DIAG_ERROR,
_("cannot obtain IP address of client: %s"),
......
......@@ -137,14 +137,14 @@ imap4d_select_status ()
io_untagged_response (RESP_OK, "[UIDNEXT %lu] Predicted next uid",
(unsigned long) uidnext);
if (unseen)
io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage ",
io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage",
(unsigned long) unseen);
io_untagged_response (RESP_NONE, "FLAGS (%s)", mflags);
/* FIXME:
- '\*' can be supported if we use the attribute_set userflag()
- Answered is still not set in the mailbox code. */
if (!(select_flags & MU_STREAM_WRITE))
io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No Permanent flags");
io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No permanent flags");
else
io_untagged_response (RESP_OK, "[PERMANENTFLAGS (%s)] Permanent flags",
mflags);
......
atconfig
atlocal
package.m4
testsuite
testsuite.dir
testsuite.log
# 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/>.
AT_SETUP([IDEF0955])
AT_CHECK([
limit=`expr $MU_ULONG_MAX - 1`
cat > input <<EOT
1 select INBOX
2 FETCH 1:$limit FLAGS
3 UID FETCH 1:$limit FLAGS
X LOGOUT
EOT
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox1,INBOX)
imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
],
[0],
[* PREAUTH IMAP4rev1 Test mode
* 5 EXISTS
* 5 RECENT
* 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
1 OK [[READ-WRITE]] SELECT Completed
2 OK FETCH Completed
* 1 FETCH (UID 1 FLAGS (\Recent))
* 2 FETCH (UID 2 FLAGS (\Recent))
* 3 FETCH (UID 3 FLAGS (\Recent))
* 4 FETCH (UID 4 FLAGS (\Recent))
* 5 FETCH (UID 5 FLAGS (\Recent))
3 OK UID FETCH Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
AT_SETUP([IDEF0956])
AT_CHECK([
limit=`expr $MU_ULONG_MAX - 1`
cat > input <<EOT
1 select INBOX
2 FETCH 1 BODY[[TEXT]]<0.$limit>
X LOGOUT
EOT
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
],
[0],
[* PREAUTH IMAP4rev1 Test mode
* 8 EXISTS
* 5 RECENT
* 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
1 OK [[READ-WRITE]] SELECT Completed
* 1 FETCH (BODY[[TEXT]]<0> {161}
ABASEMENT, n. A decent and customary mental attitude in the presence
of wealth of power. Peculiarly appropriate in an employee when
addressing an employer.
)
2 OK FETCH Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# This file is part of GNU Mailutils.
# 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/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
## ------------ ##
## package.m4. ##
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
$(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
#
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
anystate.at\
create01.at\
create02.at\
examine.at\
expunge.at\
id.at\
IDEF0955.at\
IDEF0956.at\
list.at\
search.at\
select.at\
status.at\
testsuite.at
TESTSUITE = $(srcdir)/testsuite
M4=m4
AUTOTEST = $(AUTOM4TE) --language=autotest
$(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
$(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
$(AM_V_at)mv $@.tmp $@
atconfig: $(top_builddir)/config.status
cd $(top_builddir) && ./config.status tests/$@
clean-local:
@test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
check-local: atconfig atlocal $(TESTSUITE)
@$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
# 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/>.
AT_SETUP([Non-authenticated state])
AT_KEYWORDS([anystate])
m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
IMAP4D_CHECK([],
[1 CAPABILITY
2 NOOP
3 NAMESPACE
X LOGOUT
],
[* OK IMAP4rev1 Test mode
* CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT
1 OK CAPABILITY Completed
2 OK NOOP Completed
3 BAD NAMESPACE Wrong state
* BYE Session terminating.
X OK LOGOUT Completed
])
m4_popdef([IMAP4D_OPTIONS])
AT_CLEANUP
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Mailutils test suite.
# Copyright (C) 2011 Free Software Foundation, Inc.
PATH=@abs_builddir@:@abs_top_builddir@/imap4d:$top_srcdir:$srcdir:$PATH
MU_ULONG_MAX=@MU_ULONG_MAX@
remove_untagged() {
sed '/^\*/d'
}
filter_untagged() {
sed 's/\(^\* \(OK\|BAD\|NO\|PREAUTH\)\).*/\1/'
}
remove_uidvalidity() {
sed '/^\* OK \[UIDVALIDITY/d'
}
remove_select_unagged() {
sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
}
sorted_list_output() {
sed '/^\* PREAUTH/d
/^\* OK/d
/^\* BYE/d
/^\* [0-9][0-9]* EXISTS/d
/^\* [0-9][0-9]* RECENT/d
/^\* FLAGS/d
/^[0-9X][0-9]* OK/d' | sort
}
# 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/>.
AT_SETUP([create])
AT_KEYWORDS([create create00])
AT_CHECK([
AT_DATA([input],[dnl
1 create flat
X LOGOUT
])
imap4d IMAP4D_OPTIONS < input | tr -d '\r'
find . -name flat
],
[0],
[* PREAUTH IMAP4rev1 Test mode
1 OK CREATE Completed
* BYE Session terminating.
X OK LOGOUT Completed
./flat
])
AT_CLEANUP
# 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/>.
AT_SETUP([create nested])
AT_KEYWORDS([create create01])
AT_CHECK([
AT_DATA([input],[dnl
1 create en/to/tre
X LOGOUT
])
imap4d IMAP4D_OPTIONS < input | tr -d '\r'
find . -name tre
],
[0],
[* PREAUTH IMAP4rev1 Test mode
1 OK CREATE Completed
* BYE Session terminating.
X OK LOGOUT Completed
./en/to/tre
])
AT_CLEANUP
# 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/>.
AT_SETUP([examine])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
],
[1 EXAMINE INBOX
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
* 8 EXISTS
* 5 RECENT
* OK [[UIDNEXT 9]] Predicted next uid
* OK [[UNSEEN 4]] first unseen messsage
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [[PERMANENTFLAGS ()]] No permanent flags
1 OK [[READ-ONLY]] EXAMINE Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
AT_SETUP([expunge])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,temp)
sed 's/^\(Status: .*\)/\1D/' temp > INBOX
],
[1 SELECT INBOX
2 EXPUNGE
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
* 8 EXISTS
* 5 RECENT
* 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
1 OK [[READ-WRITE]] SELECT Completed
* 1 EXPUNGED
* 1 EXPUNGED
* 1 EXPUNGED
* 5 EXISTS
* 5 RECENT
2 OK EXPUNGE Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
AT_SETUP([ID command])
AT_KEYWORDS([id])
m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
IMAP4D_CHECK([],
[1 ID NIL
X LOGOUT
],
[* OK IMAP4rev1 Test mode
1 BAD ID Wrong state
* BYE Session terminating.
X OK LOGOUT Completed
])
m4_popdef([IMAP4D_OPTIONS])
IMAP4D_CHECK([],
[1 ID NIL
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
1 OK ID Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
m4_pushdef([IMAP4D_HOMEDIR],[spool])
dnl LIST_CHECK([NAME],[KW],[ARG],[OUTPUT],[EXTRA-CODE],[filter,][expand]
m4_define([LIST_CHECK],[
AT_SETUP([$1])
AT_KEYWORDS([list $2])
IMAP4D_CHECK([
mkdir IMAP4D_HOMEDIR
m4_foreach([MAILBOX],[bigto.mbox,mbox1,mbox,relational.mbox,relational.mbox,
search.mbox,sieve.mbox,teaparty.mbox],[
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/MAILBOX,IMAP4D_HOMEDIR)
])
$5
],
[1 LIST $3
X LOGOUT
],
[$4],
[],
[sorted_list_output[]m4_if([$6],,,|[$6])],[$7])
AT_CLEANUP
])
dnl ----------------------------------------------------------------------
LIST_CHECK([asterisk],[list00],
["~" "*"],
[dnl
* LIST (\NoInferiors) "/" ~/bigto.mbox
* LIST (\NoInferiors) "/" ~/mbox
* LIST (\NoInferiors) "/" ~/mbox1
* LIST (\NoInferiors) "/" ~/relational.mbox
* LIST (\NoInferiors) "/" ~/search.mbox
* LIST (\NoInferiors) "/" ~/sieve.mbox
* LIST (\NoInferiors) "/" ~/teaparty.mbox
])
LIST_CHECK([percent],[list01],
["~" "%"],
[dnl
* LIST (\NoInferiors) "/" ~/bigto.mbox
* LIST (\NoInferiors) "/" ~/mbox
* LIST (\NoInferiors) "/" ~/mbox1
* LIST (\NoInferiors) "/" ~/relational.mbox
* LIST (\NoInferiors) "/" ~/search.mbox
* LIST (\NoInferiors) "/" ~/sieve.mbox
* LIST (\NoInferiors) "/" ~/teaparty.mbox
])
LIST_CHECK([empty ref + asterisk],[list02],
["" "*"],
[dnl
* LIST (\NoInferiors) "/" bigto.mbox
* LIST (\NoInferiors) "/" mbox
* LIST (\NoInferiors) "/" mbox1
* LIST (\NoInferiors) "/" relational.mbox
* LIST (\NoInferiors) "/" search.mbox
* LIST (\NoInferiors) "/" sieve.mbox
* LIST (\NoInferiors) "/" teaparty.mbox
* LIST (\NoInferiors) NIL INBOX
])
LIST_CHECK([root ref + asterisk],[list03],
["/" "*"],
[dnl
1 NO LIST The requested item could not be found.
])
LIST_CHECK([absolute reference + asterisk],[list04],
["$cwd/spool" "*"],
[dnl
* LIST (\NoInferiors) "/" ////bigto.mbox
* LIST (\NoInferiors) "/" ////folder/one
* LIST (\NoInferiors) "/" ////folder/two
* LIST (\NoInferiors) "/" ////mbox
* LIST (\NoInferiors) "/" ////mbox1
* LIST (\NoInferiors) "/" ////relational.mbox
* LIST (\NoInferiors) "/" ////search.mbox
* LIST (\NoInferiors) "/" ////sieve.mbox
* LIST (\NoInferiors) "/" ////teaparty.mbox
* LIST (\NoSelect) "/" ////folder
],
[mkdir IMAP4D_HOMEDIR/folder
MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
[expand])
LIST_CHECK([absolute reference + percent],[list05],
["$cwd/spool" "%"],
[dnl
* LIST (\NoInferiors) "/" ////bigto.mbox
* LIST (\NoInferiors) "/" ////mbox
* LIST (\NoInferiors) "/" ////mbox1
* LIST (\NoInferiors) "/" ////relational.mbox
* LIST (\NoInferiors) "/" ////search.mbox
* LIST (\NoInferiors) "/" ////sieve.mbox
* LIST (\NoInferiors) "/" ////teaparty.mbox
* LIST (\NoSelect) "/" ////folder
],
[mkdir IMAP4D_HOMEDIR/folder
MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
[expand])
LIST_CHECK([absolute reference + mailbox],[list06],
["$cwd/spool" "search.mbox"],
[dnl
* LIST (\NoInferiors) "/" ////search.mbox
],
[],
[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
[expand])
LIST_CHECK([empty reference + INBOX],[list07],
["" INBOX],
[dnl
* LIST (\NoInferiors) NIL INBOX
])
dnl ----------------------------------------------------------------------
m4_popdef([IMAP4D_HOMEDIR])
# 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 SEARCH_CHECK([NAME],[KW],[ARG],[OUTPUT])
m4_define([SEARCH_CHECK],[
AT_SETUP([$1])
AT_KEYWORDS([search $2])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
],
[1 SELECT INBOX
2 SEARCH $3
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
* SEARCH $4
2 OK SEARCH Completed
* BYE Session terminating.
X OK LOGOUT Completed
],
[],
[remove_select_unagged])
AT_CLEANUP
])
dnl ----------------------------------------------------------------------
# <message set> Messages with message sequence numbers
# corresponding to the specified message sequence
# number set
SEARCH_CHECK([search sequence number],[search00],
[1:*],[1 2 3 4 5 6 7 8])
# ALL All messages in the mailbox; the default initial
# key for ANDing.
SEARCH_CHECK([search all],[search01],
[ALL],[1 2 3 4 5 6 7 8])
# NEW Messages that have the \Recent flag set but not the
# \Seen flag. This is functionally equivalent to
# "(RECENT UNSEEN)".
SEARCH_CHECK([search new],[search02],
[NEW],[4 5 6 7 8])
# FROM <string> Messages that contain the specified string in the
# envelope structure's FROM field.
SEARCH_CHECK([search from personal],[search03],
[FROM corrector],[2 4 8])
SEARCH_CHECK([search from email],[search04],
[FROM lexi@example.net],[1 3 5 6 7])
# LARGER <n> Messages with an [RFC-822] size larger than the
# specified number of octets.
SEARCH_CHECK([search larger],[search05],
[LARGER 512],[3 4])
# SMALLER <n> Messages with an [RFC-822] size smaller than the
# specified number of octets.
SEARCH_CHECK([search smaller],[search06],
[SMALLER 400],[7 8])
# SUBJECT <string> Messages that contain the specified string in the
# envelope structure's SUBJECT field.
SEARCH_CHECK([search subject],[search07],
[SUBJECT "Alliance"],[6])
# 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.
SEARCH_CHECK([search header],[search08],
[HEADER Message-Id "<200207291200.3303@example.org>"],[3])
# CC <string> Messages that contain the specified string in the
# envelope structure's CC field.
SEARCH_CHECK([search cc],[search09],
[CC Corrector],[6])
# TO <string> Messages that contain the specified string in the
# envelope structure's TO field.
SEARCH_CHECK([search to],[search10],
[TO editor+recheck],[7])
# SENTBEFORE <date>
# Messages whose [RFC-822] Date: header is earlier
# than the specified date.
SEARCH_CHECK([search sentbefore],[search11],
[SENTBEFORE "30-Jul-2002"],[1 2])
# SENTSINCE <date>
# Messages whose [RFC-822] Date: header is within or
# later than the specified date.
SEARCH_CHECK([search sentsince],[search12],
[SENTSINCE "31-Jul-2002"],[5 6 7 8])
# BEFORE <date> Messages whose internal date is earlier than the
# specified date.
SEARCH_CHECK([search beforedate],[search13],
[BEFORE "30-Jul-2002"],[1])
# SINCE <date> Messages whose internal date is within or later
# than the specified date.
SEARCH_CHECK([search since],[search14],
[SINCE "30-Jul-2002"],[2 3 4 5 6 7 8])
# ANSWERED Messages with the \Answered flag set.
SEARCH_CHECK([search answered],[search15],
[ANSWERED],[2 3])
# TEXT <string> Messages that contain the specified string in the
# header or body of the message.
SEARCH_CHECK([search text],[search16],
[TEXT person],[2 5 8])
# When multiple keys are specified, the result is the intersection
# (AND function) of all the messages that match those keys.
SEARCH_CHECK([search multiple keys (implicit AND) 1],[search17],
[TEXT person FROM corrector],[2 8])
SEARCH_CHECK([search multiple keys (implicit AND) 2],[search18],
[SENTSINCE "30-Jul-2002" SENTBEFORE "31-Jul-2002"],[3 4])
# OR <search-key1> <search-key2>
# Messages that match either search key.
SEARCH_CHECK([search or],[search19],
[OR FROM corrector ANSWERED],[2 3 4 8])
# Test precedence
SEARCH_CHECK([precedence 1],[search20],
[(OR FROM corrector ANSWERED) SENTSINCE "30-Jul-2002"],[3 4 8])
SEARCH_CHECK([precedence 2],[search21],
[OR FROM corrector ANSWERED SENTSINCE "30-Jul-2002"],[3 4 8])
SEARCH_CHECK([precedence 3],[search22],
[OR FROM corrector (ANSWERED SENTSINCE "30-Jul-2002")],[2 3 4 8])
dnl ----------------------------------------------------------------------
# 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/>.
AT_SETUP([select])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
],
[1 SELECT INBOX
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
* 8 EXISTS
* 5 RECENT
* 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
1 OK [[READ-WRITE]] SELECT Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
AT_SETUP([status])
IMAP4D_CHECK([
MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
],
[1 STATUS INBOX (MESSAGES RECENT UNSEEN UIDNEXT)
X LOGOUT
],
[* PREAUTH IMAP4rev1 Test mode
* STATUS INBOX (MESSAGES 8 RECENT 5 UNSEEN 5 UIDNEXT 9)
1 OK STATUS Completed
* BYE Session terminating.
X OK LOGOUT Completed
])
AT_CLEANUP
# 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/>.
m4_include([testsuite.inc])
m4_define([IMAP4D_HOMEDIR])
m4_define([IMAP4D_DEFAULT_OPTIONS],[dnl
--no-site-config dnl
--no-user-config dnl
--test dnl
--set logging.syslog=0 dnl
--set logging.severity=notice dnl
--set .gsasl.enable=0 dnl
--set '|homedir='`pwd`m4_if([IMAP4D_HOMEDIR],,,/[IMAP4D_HOMEDIR]) dnl
--set '|mailbox|folder='`pwd` dnl
--set '|mailbox|mailbox-pattern='`pwd`/INBOX dnl
])
m4_define([IMAP4D_PREAUTH_OPTIONS],[dnl
IMAP4D_DEFAULT_OPTIONS dnl
--preauth dnl
])
m4_define([IMAP4D_OPTIONS],[IMAP4D_PREAUTH_OPTIONS])
dnl ------------------------------------------------------------
dnl IMAP4D_CHECK([PREP], [INPUT], [STDOUT = `'], [STDERR = `'],
dnl [FILTER = `'],[expand])
dnl
m4_pushdef([IMAP4D_CHECK],[
cwd=`pwd`
m4_if([$6],,[dnl
AT_DATA([input],[$2])dnl
],[cat > input <<EOT
[$2]
EOT
])
$1
AT_CHECK([
imap4d IMAP4D_OPTIONS < input | tr -d '\r' | dnl
m4_if([$5],,[remove_uidvalidity],[$5])
],
[0],
[$3],
[$4])
])
AT_INIT
AT_TESTED([imap4d])
MUT_VERSION(imap4d)
m4_include([anystate.at])
m4_include([id.at])
m4_include([select.at])
m4_include([examine.at])
m4_include([status.at])
m4_include([expunge.at])
m4_include([create01.at])
m4_include([create02.at])
AT_BANNER([LIST])
m4_include([list.at])
AT_BANNER([SEARCH])
m4_include([search.at])
AT_BANNER([IDEF Checks])
m4_include([IDEF0955.at])
m4_include([IDEF0956.at])
......@@ -21,6 +21,7 @@
struct mu_gsasl_module_data
{
int enable;
char *service;
char *realm;
char *hostname;
......@@ -28,13 +29,15 @@ struct mu_gsasl_module_data
char *cram_md5_pwd;
};
int mu_gsasl_module_init (enum mu_gocs_op, void *);
extern struct mu_gsasl_module_data mu_gsasl_module_data;
int mu_gsasl_enabled (void);
#ifdef WITH_GSASL
#include <gsasl.h>
int mu_gsasl_module_init (enum mu_gocs_op, void *);
extern struct mu_gsasl_module_data mu_gsasl_module_data;
int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport,
Gsasl_session *ctx, int flags);
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)
return MU_ERR_MBX_REMOVED;
if (!(mbox->flags & _MU_MAILBOX_OPEN))
return _MU_MAILBOX_OPEN;
if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
return 0;
mu_mailbox_messages_count (mbox, &total);
......@@ -375,7 +375,7 @@ int
mu_mailbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
{
_MBOX_CHECK_Q (mbox, _append_message);
if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
return EACCES;
return mbox->_append_message (mbox, msg);
}
......@@ -422,7 +422,7 @@ int
mu_mailbox_sync (mu_mailbox_t mbox)
{
_MBOX_CHECK_Q (mbox, _sync);
if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
return 0;
return mbox->_sync (mbox);
}
......@@ -438,7 +438,7 @@ int
mu_mailbox_expunge (mu_mailbox_t mbox)
{
_MBOX_CHECK_Q (mbox, _expunge);
if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
return EACCES;
return mbox->_expunge (mbox);
}
......
......@@ -38,7 +38,12 @@
#include <gsasl.h>
struct mu_gsasl_module_data mu_gsasl_module_data = {
SITE_CRAM_MD5_PWD
1,
NULL,
NULL,
NULL,
NULL,
SITE_CRAM_MD5_PWD
};
int
......@@ -49,6 +54,12 @@ mu_gsasl_module_init (enum mu_gocs_op op, void *data)
return 0;
}
int
mu_gsasl_enabled (void)
{
return mu_gsasl_module_data.enable;
}
static enum mu_filter_result
_gsasl_encoder (void *xdata,
......@@ -214,5 +225,10 @@ mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport,
mu_stream_unref (out);
return rc;
}
#else
int
mu_gsasl_enabled (void)
{
return 0;
}
#endif
......
......@@ -25,6 +25,8 @@
static struct mu_gsasl_module_data gsasl_settings;
static struct mu_cfg_param mu_gsasl_param[] = {
{ "enable", mu_cfg_bool, &gsasl_settings.enable, 0, NULL,
N_("Enable GSASL (default)") },
{ "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
N_("Name of GSASL password file."),
N_("file") },
......