/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "str.h"
#include "message-part-data.h"
#include "message-parser.h"
#include "imap-envelope.h"
#include "test-common.h"
struct parse_test {
const char *message;
const char *envelope;
};
/* Tests copied from imaptest */
{
.message =
"Message-ID: <msg@id>\n"
"In-Reply-To: <reply@to.id>\n"
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"Subject: subject header\n"
"From: From Real <fromuser@fromdomain.org>\n"
"To: To Real <touser@todomain.org>\n"
"Cc: Cc Real <ccuser@ccdomain.org>\n"
"Bcc: Bcc Real <bccuser@bccdomain.org>\n"
"Sender: Sender Real <senderuser@senderdomain.org>\n"
"Reply-To: ReplyTo Real <replytouser@replytodomain.org>\n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" "
"\"subject header\" "
"((\"From Real\" NIL \"fromuser\" \"fromdomain.org\")) "
"((\"Sender Real\" NIL \"senderuser\" \"senderdomain.org\")) "
"((\"ReplyTo Real\" NIL \"replytouser\" \"replytodomain.org\")) "
"((\"To Real\" NIL \"touser\" \"todomain.org\")) "
"((\"Cc Real\" NIL \"ccuser\" \"ccdomain.org\")) "
"((\"Bcc Real\" NIL \"bccuser\" \"bccdomain.org\")) "
"\"<reply@to.id>\" \"<msg@id>\""
}, {
.message =
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"From: user@domain\n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
"((NIL NIL \"user\" \"domain\")) "
"((NIL NIL \"user\" \"domain\")) "
"((NIL NIL \"user\" \"domain\")) NIL NIL NIL NIL NIL"
}, {
.message =
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"From: user@domain\n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
"((NIL NIL \"user\" \"domain\")) "
"((NIL NIL \"user\" \"domain\")) "
"((NIL NIL \"user\" \"domain\")) NIL NIL NIL NIL NIL"
}, {
.message =
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"From: user@domain (Real Name)\n"
"To: group: g1@d1.org, g2@d2.org;, group2: g3@d3.org;\n"
"Cc: group:;, group2: (foo) ;\n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"((NIL NIL \"group\" NIL)"
"(NIL NIL \"g1\" \"d1.org\")"
"(NIL NIL \"g2\" \"d2.org\")"
"(NIL NIL NIL NIL)"
"(NIL NIL \"group2\" NIL)"
"(NIL NIL \"g3\" \"d3.org\")"
"(NIL NIL NIL NIL)) "
"((NIL NIL \"group\" NIL)(NIL NIL NIL NIL)"
"(NIL NIL \"group2\" NIL)(NIL NIL NIL NIL)) "
"NIL NIL NIL"
}, {
.message =
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"From: user@domain (Real Name)\n"
"Sender: \n"
"Reply-To: \n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"((\"Real Name\" NIL \"user\" \"domain\")) "
"NIL NIL NIL NIL NIL"
}, {
.message =
"Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
"From: <@route:user@domain>\n"
"\n"
"body\n",
.envelope =
"\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
"((NIL \"@route\" \"user\" \"domain\")) "
"((NIL \"@route\" \"user\" \"domain\")) "
"((NIL \"@route\" \"user\" \"domain\")) "
"NIL NIL NIL NIL NIL"
}
};
static struct message_part_envelope *
{
int ret;
}
test_assert(ret < 0);
return envlp;
}
static void test_imap_envelope_write(void)
{
unsigned int i;
for (i = 0; i < parse_tests_count; i++) T_BEGIN {
pool_unref(&pool);
test_end();
} T_END;
}
static void test_imap_envelope_parse(void)
{
const char *error;
unsigned int i;
bool ret;
for (i = 0; i < parse_tests_count; i++) T_BEGIN {
if (ret) {
str_truncate(str, 0);
} else {
}
pool_unref(&pool);
test_end();
} T_END;
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}