bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch /* Tests copied from imaptest */
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Message-ID: <msg@id>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "In-Reply-To: <reply@to.id>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Subject: subject header\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: From Real <fromuser@fromdomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "To: To Real <touser@todomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Cc: Cc Real <ccuser@ccdomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Bcc: Bcc Real <bccuser@bccdomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Sender: Sender Real <senderuser@senderdomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Reply-To: ReplyTo Real <replytouser@replytodomain.org>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"subject header\" "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"From Real\" NIL \"fromuser\" \"fromdomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Sender Real\" NIL \"senderuser\" \"senderdomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"ReplyTo Real\" NIL \"replytouser\" \"replytodomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"To Real\" NIL \"touser\" \"todomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Cc Real\" NIL \"ccuser\" \"ccdomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Bcc Real\" NIL \"bccuser\" \"bccdomain.org\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"<reply@to.id>\" \"<msg@id>\""
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: user@domain\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) NIL NIL NIL NIL NIL"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: user@domain\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"user\" \"domain\")) NIL NIL NIL NIL NIL"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: user@domain (Real Name)\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "To: group: g1@d1.org, g2@d2.org;, group2: g3@d3.org;\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Cc: group:;, group2: (foo) ;\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"group\" NIL)"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL \"g1\" \"d1.org\")"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL \"g2\" \"d2.org\")"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL NIL NIL)"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL \"group2\" NIL)"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL \"g3\" \"d3.org\")"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL NIL NIL)) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL NIL \"group\" NIL)(NIL NIL NIL NIL)"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "(NIL NIL \"group2\" NIL)(NIL NIL NIL NIL)) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "NIL NIL NIL"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: user@domain (Real Name)\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Reply-To: \n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((\"Real Name\" NIL \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "NIL NIL NIL NIL NIL"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "From: <@route:user@domain>\n"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL \"@route\" \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL \"@route\" \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "((NIL \"@route\" \"user\" \"domain\")) "
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch "NIL NIL NIL NIL NIL"
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Boschstatic const unsigned int parse_tests_count = N_ELEMENTS(parse_tests);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch input = i_stream_create_from_data(message, strlen(message));
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP |
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch while ((ret = message_parser_parse_next_block(parser, &block)) > 0) {
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch message_part_envelope_parse_from_header(pool, &envlp, block.hdr);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch unsigned int i;
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch for (i = 0; i < parse_tests_count; i++) T_BEGIN {
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch pool_t pool = pool_alloconly_create("imap envelope write", 1024);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch test_begin(t_strdup_printf("imap envelope write [%u]", i));
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch test_assert(strcmp(str_c(str), test->envelope) == 0);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch unsigned int i;
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch for (i = 0; i < parse_tests_count; i++) T_BEGIN {
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch pool_t pool = pool_alloconly_create("imap envelope parse", 1024);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch test_begin(t_strdup_printf("imap envelope parser [%u]", i));
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch ret = imap_envelope_parse(test->envelope, pool, &envlp, &error);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch test_assert(strcmp(str_c(str), test->envelope) == 0);
30116399ebac74cf4ea0daefb65c9fba742e0773Stephan Bosch static void (*const test_functions[])(void) = {