diff options
| author | Sam Varshavchik | 2022-03-05 23:32:10 -0500 |
|---|---|---|
| committer | Sam Varshavchik | 2022-03-06 08:41:58 -0500 |
| commit | a219cd3c45aa2545a7a641acb277acb5e8be87f9 (patch) | |
| tree | 4cf5a163ddc15e88a5739dfce2a974edbadb8b9b | |
| parent | 4c4693e3497b7723446d360a04522de9cee8b063 (diff) | |
| download | courier-libs-a219cd3c45aa2545a7a641acb277acb5e8be87f9.tar.bz2 | |
Add additional tests.
| -rw-r--r-- | imap/.gitignore | 1 | ||||
| -rw-r--r-- | imap/Makefile.am | 19 | ||||
| -rw-r--r-- | imap/pop3dserver.c | 22 | ||||
| -rw-r--r-- | imap/pop3testsuite | 130 | ||||
| -rw-r--r-- | imap/pop3testsuite.txt | 115 | ||||
| -rw-r--r-- | imap/testpop3dserver.c | 6 |
6 files changed, 285 insertions, 8 deletions
diff --git a/imap/.gitignore b/imap/.gitignore index 663429e..6b4c6f5 100644 --- a/imap/.gitignore +++ b/imap/.gitignore @@ -49,5 +49,6 @@ /pop3d.dist /pop3d.dist.in /pop3d.pam +/pop3d.testmock /pop3login /testsuitefix.pl diff --git a/imap/Makefile.am b/imap/Makefile.am index 5aade68..5f91b41 100644 --- a/imap/Makefile.am +++ b/imap/Makefile.am @@ -23,10 +23,12 @@ EXTRA_DIST=testsuite testsuite.txt smaptestsuite smaptestsuite.txt \ mkpop3dcert.html.in mkpop3dcert.8.in \ courierpop3d.html.in courierpop3d.8.in \ README.proxy README.proxy.html \ - imapd.cnf.gnutls pop3d.cnf.gnutls + imapd.cnf.gnutls pop3d.cnf.gnutls \ + pop3testsuite pop3testsuite.txt noinst_SCRIPTS=mkimapdcert mkpop3dcert mkdhparams -noinst_PROGRAMS=imaplogin imapd imapd.testmockpurge pop3login pop3d +noinst_PROGRAMS=imaplogin imapd imapd.testmockpurge pop3login pop3d \ + pop3d.testmock noinst_DATA=imapd.8 imapd.html imapd.cnf pop3d.cnf \ makeimapaccess.html makeimapaccess.8 \ @@ -99,6 +101,10 @@ pop3d_SOURCES=pop3dserver.c pop3dcapa.c pop3d_DEPENDENCIES=libpop3d.la pop3d_LDADD=libpop3d.la @LDAUTH@ -lcourierauth -lcourier-unicode +pop3d_testmock_SOURCES=testpop3dserver.c pop3dcapa.c +pop3d_testmock_DEPENDENCIES=libpop3d.la +pop3d_testmock_LDADD=libpop3d.la @LDAUTH@ -lcourierauth -lcourier-unicode + HTML2TXT=links -dump -no-numbering README: README.html @@ -231,9 +237,13 @@ check-am: rm -f confmdmemleak; \ IMAPINVOKE='@SHELL@ $(srcdir)/testsuitevalgrind ./imapd'; export IMAPINVOKE; \ export PERL=@PERL@; @SHELL@ -x $(srcdir)/smaptestsuite 2>&1 | tee confmderror.txt; test -f confmdmemleak || exit 0; exit 1 - rm -f confmderror.txt rm -rf confmdtest + @SHELL@ $(srcdir)/pop3testsuite | sed 's/^--=_.*/--mimeboundary/;s/ENOMEM.*/ENOMEM/;s/boundary=.*/boundary=/' | cmp -s - $(srcdir)/pop3testsuite.txt + rm -f confmdmemleak; \ + POP3INVOKE='@SHELL@ $(srcdir)/testsuitevalgrind ./pop3d.testmock' \ + @SHELL@ -x $(srcdir)/pop3testsuite; \ + test -f confmdmemleak || exit 0; exit 1 testsuite-imap: @chmod +x testsuitefix.pl @@ -242,3 +252,6 @@ testsuite-imap: testsuite-smap: @chmod +x testsuitefix.pl @LC_ALL=C; export LC_ALL; test "@smap@" = "yes" || exit 0; export PERL=@PERL@; @SHELL@ $(srcdir)/smaptestsuite | ./testsuitefix.pl | sort + +testsuite-pop3: + @LC_ALL=C @SHELL@ pop3testsuite | sed 's/^--=_.*/--mimeboundary/;s/ENOMEM.*/ENOMEM/;s/boundary=.*/boundary=/' diff --git a/imap/pop3dserver.c b/imap/pop3dserver.c index 5e938ad..82a1ec0 100644 --- a/imap/pop3dserver.c +++ b/imap/pop3dserver.c @@ -60,6 +60,14 @@ #define POP3DLIST "courierpop3dsizelist" #define LISTVERSION 3 +#ifndef RUNTIME_START +#define RUNTIME_START time(NULL) +#endif + +#ifndef RUNTIME_CUR +#define RUNTIME_CUR time(NULL) +#endif + extern void pop3dcapa(); extern void pop3dlang(const char *); @@ -190,7 +198,7 @@ static struct msglist **readpop3dlist(unsigned long *uid) int vernum=0; unsigned long size; - uidv=time(NULL); + uidv=RUNTIME_CUR; if (fp == NULL || fgets(linebuf, sizeof(linebuf)-1, fp) == NULL || @@ -299,6 +307,9 @@ static int savepop3dlist(struct msglist **a, size_t cnt, struct maildir_tmpcreate_info createInfo; +#ifdef SAVEHOOK + SAVEHOOK(); +#endif maildir_tmpcreate_init(&createInfo); createInfo.uniq="pop3"; @@ -488,7 +499,9 @@ static void sortmsgs() } if (prev_list[n]) + { savesizes=1; + } for (i=0; prev_list[i]; i++) { @@ -728,7 +741,7 @@ static void do_retr(unsigned i, unsigned *lptr) if (msglist_a[i]->isutf8 && !utf8_enabled) { - sprintf(boundary, "=_%d-%d", (int)getpid(), (int)time(NULL)); + sprintf(boundary, "=_%d-%d", (int)getpid(), (int)RUNTIME_CUR); sprintf(wrapheader, MIMEWRAPTXT, boundary, boundary, boundary, mime_message_type); @@ -910,7 +923,7 @@ static void acctout(const char *disc) libmail_str_size_t(top_count, num1); libmail_str_size_t(retr_count, num2); - libmail_str_time_t(time(NULL)-start_time, num3); + libmail_str_time_t(RUNTIME_CUR-start_time, num3); libmail_str_size_t(bytes_received_count, numAR); libmail_str_size_t(bytes_sent_count, numAS); @@ -1121,11 +1134,10 @@ char *n; int main(int argc, char **argv) { char *p; - #ifdef HAVE_SETVBUF_IOLBF setvbuf(stderr, NULL, _IOLBF, BUFSIZ); #endif - time(&start_time); + start_time=RUNTIME_START; if ((authaddr=getenv("AUTHADDR")) == NULL || *authaddr == 0) diff --git a/imap/pop3testsuite b/imap/pop3testsuite new file mode 100644 index 0000000..6ce6c1e --- /dev/null +++ b/imap/pop3testsuite @@ -0,0 +1,130 @@ +#!/bin/sh + +# Maintainer's sanity check + +OPTIONS="" +export OPTIONS +TZ=EST5EDT +export TZ + +echo '****************************' >&2 +echo '* Sanity check in progress *' >&2 +echo '****************************' >&2 +#test ! -d confmdtest || find confmdtest -exec chmod u+rwx {} \; +#test ! -d confmdtest2 || find confmdtest2 -exec chmod u+rwx {} \; +test ! -d confmdtest || chmod -R u+rwx confmdtest +rm -rf confmdtest +../maildir/maildirmake confmdtest || exit 1 + +if test "$POP3INVOKE" = "" +then + POP3INVOKE="./pop3d.testmock" +fi + +cat >confmdtest/new/msg1 <<EOF +Subject: test +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +$POP3INVOKE confmdtest <<EOF +STAT +UIDL +RETR 1 +TOP 1 1 +EOF + +cat >confmdtest/new/msg2 <<EOF +Subject: test 2 +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +$POP3INVOKE confmdtest <<EOF +STAT +UIDL 1 +UIDL 2 +TOP 1 0 +EOF +mv confmdtest/cur/msg2:2, confmdtest/cur/msg2:2,S || exit 1 +rm confmdtest/cur/msg1:2,S || exit 1 +cat >confmdtest/new/msg3 <<EOF +Subject: test 3 +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +$POP3INVOKE confmdtest <<EOF +STAT +UIDL +TOP 1 0 +TOP 2 0 +EOF +rm confmdtest/cur/msg3:2, +$POP3INVOKE confmdtest <<EOF +STAT +EOF +cat confmdtest/courierpop3dsizelist +cat >confmdtest/new/msg4 <<EOF +Subject: test 4 +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +POP3DEBUGNOSAVE=1 $POP3INVOKE confmdtest <<EOF +STAT +UIDL +DELE 1 +RSET +EOF +ls confmdtest/cur +rm -f confmdtest/cur/* +cat >confmdtest/new/msg5 <<EOF +Subject: test 5 +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +POP3DEBUGNOSAVE=1 $POP3INVOKE confmdtest <<EOF +STAT +UIDL +DELE 1 +QUIT +EOF +ls confmdtest/cur +cat >confmdtest/new/msg6 <<EOF +Subject: test 6 Привет +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +$POP3INVOKE confmdtest <<EOF +LIST 1 +EOF +cat >confmdtest/new/msg7 <<EOF +Subject: test 7 +From: nobody@example.com + +Line 1 +Line 2 +Line 3 +EOF +UTF8=0 $POP3INVOKE confmdtest <<EOF | sed 's/[1-9][0-9]* octets follow/octets follow/' +LIST +RETR 1 +UTF8 +RETR 1 +EOF +rm -rf confmdtest diff --git a/imap/pop3testsuite.txt b/imap/pop3testsuite.txt new file mode 100644 index 0000000..7ef1680 --- /dev/null +++ b/imap/pop3testsuite.txt @@ -0,0 +1,115 @@ ++OK logged in.
++OK 1 67
++OK
+1 UID1-200
+.
++OK 67 octets follow.
+Subject: test
+From: nobody@example.com
+
+Line 1
+Line 2
+Line 3
+.
++OK headers follow.
+Subject: test
+From: nobody@example.com
+
+Line 1
+.
++OK logged in.
++OK 2 136
++OK 1 UID1-200
++OK 2 UID2-200
++OK headers follow.
+Subject: test
+From: nobody@example.com
+
+.
++OK logged in.
++OK 2 138
++OK
+1 UID2-200
+2 UID3-200
+.
++OK headers follow.
+Subject: test 2
+From: nobody@example.com
+
+.
++OK headers follow.
+Subject: test 3
+From: nobody@example.com
+
+.
++OK logged in.
++OK 1 69
+/3 4 200 +msg2:2,S 69 2:200:0 ++OK logged in.
++OK 1 69
++OK
+1 UID2-200
+.
++OK Deleted.
++OK Resurrected.
+msg2:2,S +msg4:2, ++OK logged in.
++OK 1 69
++OK
+1 ENOMEM +.
++OK Deleted.
++OK Bye-bye.
++OK logged in.
++OK 1 82
++OK logged in.
++OK POP3 clients that break here, they violate STD53.
+1 82
+2 69
+.
++OK octets follow.
+From: Mail Delivery Subsystem <postmaster>
+Subject: Cannot display Unicode content
+Mime-Version: 1.0
+Content-Type: multipart/mixed; boundary= +
+
+
+--mimeboundary +Content-Type: text/plain
+
+This E-mail message was determined to be Unicode-formatted
+but your E-mail reader does not support Unicode E-mail.
+
+Please use an E-mail reader that supports POP3 with UTF-8
+(see https://tools.ietf.org/html/rfc6856.html).
+
+This can also happen when the sender's E-mail program does not
+correctly format the sent message.
+
+The original message is included as a separate attachment
+so that it can be downloaded manually.
+
+--mimeboundary +Content-Type: message/global
+
+Subject: test 6 Привет
+From: nobody@example.com
+
+Line 1
+Line 2
+Line 3
+
+--mimeboundary +.
++OK UTF8 enabled
++OK octets follow.
+Subject: test 6 Привет
+From: nobody@example.com
+
+Line 1
+Line 2
+Line 3
+.
diff --git a/imap/testpop3dserver.c b/imap/testpop3dserver.c new file mode 100644 index 0000000..5164854 --- /dev/null +++ b/imap/testpop3dserver.c @@ -0,0 +1,6 @@ +#define RUNTIME_START 100 +#define RUNTIME_CUR 200 + +#define SAVEHOOK() do { if (getenv("POP3DEBUGNOSAVE")) return -1; } while (0) + +#include "pop3dserver.c" |
