|
|
@ -2,10 +2,127 @@ |
|
|
|
|
|
|
|
#include "../src/types.hh" |
|
|
|
|
|
|
|
namespace |
|
|
|
{ |
|
|
|
static const char* mail1_eml = |
|
|
|
"Return-Path: <alice@pep-project.org>\r\n" |
|
|
|
"X-Original-To: alice@pep-project.org\r\n" |
|
|
|
"Delivered-To: alice@pep-project.org\r\n" |
|
|
|
"Received: from localhost (localhost [127.0.0.1])\r\n" |
|
|
|
"\tby dragon.pibit.ch (Postfix) with ESMTP id B84AF171C06F\r\n" |
|
|
|
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:39 +0100 (CET)\r\n" |
|
|
|
"Received: from dragon.pibit.ch ([127.0.0.1])\r\n" |
|
|
|
"\tby localhost (dragon.pibit.ch [127.0.0.1]) (amavisd-new, port 10024)\r\n" |
|
|
|
"\twith ESMTP id q0wZqHMoT1gS for <alice@pep-project.org>;\r\n" |
|
|
|
"\tWed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n" |
|
|
|
"Received: from Alice-PC.local (unknown [192.168.128.20])\r\n" |
|
|
|
"\tby dragon.pibit.ch (Postfix) with ESMTPSA id 563DD171C06A\r\n" |
|
|
|
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n" |
|
|
|
"To: Bob <bob@pep-project.org>\r\n" |
|
|
|
"From: Alice <alice@pep-project.org>\r\n" |
|
|
|
"Cc: Carol Couscous <carol.couscous+private@pep.lol>, Dave Doe (III) \r\n" |
|
|
|
" Dexter <dave-dexter@pep.ooo>, dodo@pep.lol, \"Eve @ Evil\" <eve@evil.lol>\r\n" |
|
|
|
" Mallory =?UTF-8?B?TcO2bGxlcg==?= (private) <\"mallory @ moeller\"@sinister.aq>\r\n" |
|
|
|
"Subject: =?UTF-8?B?UsO4ZGdyw7hkIG1lZCBmbMO4ZGU=?=\r\n" |
|
|
|
"Openpgp: preference=signencrypt\r\n" |
|
|
|
"Organization: =?UTF-8?B?8J+Ukg==?=\r\n" |
|
|
|
"Message-ID: <65a2df2c-ddc8-0875-a142-21acf62ed467@pep-project.org>\r\n" |
|
|
|
"References: <msg-alfa@pep.id> <msg-bravo@pep.aq> <lol-123456789@intern.sc.ful-lol.example>\r\n" |
|
|
|
" <msg-charlie@pep.aq>\r\n" |
|
|
|
"In-Reply-To: <msg-reply-0815@pep.aq>\r\n" |
|
|
|
"Date: Wed, 16 Jan 2019 16:29:30 +0100\r\n" |
|
|
|
"User-Agent: B\r\n" |
|
|
|
"MIME-Version: 1.0\r\n" |
|
|
|
"Content-Type: multipart/mixed;\r\n" |
|
|
|
" boundary=\"==pEp_01==\"\r\n" |
|
|
|
"\r\n" |
|
|
|
"This is a Multipart MIME message.\r\n" |
|
|
|
"--==pEp_01==\r\n" |
|
|
|
"Content-Type: multipart/alternative; boundary=\"==pEp_02==\";\r\n" |
|
|
|
" protected-headers=\"v1\"\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_02==\r\n" |
|
|
|
"Content-Type: text/plain; charset=\"utf-8\"\r\n" |
|
|
|
"Content-Language: en-US\r\n" |
|
|
|
"Content-Transfer-Encoding: quoted-printable\r\n" |
|
|
|
"\r\n" |
|
|
|
"R=C3=B8dgr=C3=B8d med fl=C3=B8de?\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_02==\r\n" |
|
|
|
"Content-Type: multipart/related; boundary=\"==pEp_LoL==\";\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_LoL==\r\n" |
|
|
|
"Content-Type: text/html; charset=\"ISO-8859-1\";\r\n" |
|
|
|
"Content-Transfer-Encoding: quoted-printable\r\n" |
|
|
|
"\r\n" |
|
|
|
"<html lang=3D=22de=22><body>=DCbergr=F6=DFen=E4nderung: 1=\r\n" |
|
|
|
"0=80.</body></html>\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_LoL==\r\n" |
|
|
|
"Content-Type: image/png; name=\"rebeccapurple-circle.png\"\r\n" |
|
|
|
"Content-Language: en-US\r\n" |
|
|
|
"Content-ID: <rebeccapurple-circle-fb25fbb3-fd0b-46af-b567-7d1aa5725c49@pep.lol>\r\n" |
|
|
|
"Content-Transfer-Encoding: base64\r\n" |
|
|
|
"Content-Disposition: inline;\r\n" |
|
|
|
" filename*0*=utf-8'en-US'rebeccapurple;\r\n" |
|
|
|
" filename*1*=%2Dcircle.png;\r\n" |
|
|
|
"\r\n" |
|
|
|
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n" |
|
|
|
"H0lEQVQIHWP4Ic/wgJ3hADNDAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_LoL==--\r\n" // end of multipart/related
|
|
|
|
"\r\n" |
|
|
|
"--==pEp_02==--\r\n" // end of multipart/alternative
|
|
|
|
"\r\n" |
|
|
|
"--==pEp_01==\r\n" // first "real" attachment, 2nd in bloblist
|
|
|
|
"Content-Type: application/octet-stream; name=\"This is a long\r\n" |
|
|
|
" file name so it is split to multiple\r\n" |
|
|
|
" physical lines.bin\"\r\n" |
|
|
|
"Content-Language: en-US\r\n" |
|
|
|
"Content-Transfer-Encoding: base64\r\n" |
|
|
|
"Content-Disposition: attachment;\r\n" |
|
|
|
" filename*0=\"This is a long file name so it is split to\";\r\n" |
|
|
|
" filename*1=\" multiple physical lines.bin\";\r\n" |
|
|
|
"\r\n" |
|
|
|
"w5xiZXJncsO2w59lbsOkbmRlcnVuZyEK\r\n" |
|
|
|
"\r\n" |
|
|
|
"--==pEp_01==\r\n" // another text/plain part, 3rd in bloblist
|
|
|
|
"Content-Type: text/plain; charset=\"ISO-8859-15\";\r\n" |
|
|
|
"Content-Transfer-Encoding: quoted-printable\r\n" |
|
|
|
"\r\n" |
|
|
|
"=DCbergr=F6=DFen=E4nderung: 10=A4.\r\n" |
|
|
|
"--==pEp_01==\r\n" // an attached PNG image with bizarre filename as 4th and last element in bloblist
|
|
|
|
"Content-Type: image/png; name=\"=?UTF-8?B?8J+SqSDwn5iAIPCf?=" |
|
|
|
" =?UTF-8?B?kqkg8J+YgCDwn5KpIPCfmIAg8J+SqSDwn5iAIPCfkqkg8J+YgCDwn5KpIPCfm?=" |
|
|
|
" =?UTF-8?B?IAg8J+SqSDwn5iAIPCfkqkg8J+YgC5wbmc=?=\"\r\n" |
|
|
|
"Content-Language: en-US\r\n" |
|
|
|
"Content-Transfer-Encoding: base64\r\n" |
|
|
|
"Content-Disposition: attachment;\r\n" |
|
|
|
" filename*0*=utf-8''%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0;\r\n" |
|
|
|
" filename*1*=%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9;\r\n" |
|
|
|
" filename*2*=%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F;\r\n" |
|
|
|
" filename*3*=%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20;\r\n" |
|
|
|
" filename*4*=%F0%9F%92%A9%20%F0%9F%98%80.png\r\n" |
|
|
|
"\r\n" |
|
|
|
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n" |
|
|
|
" H0lEQVQIHWP4Ic/wgJ3hADN\r\n" |
|
|
|
"DAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n" |
|
|
|
"--==pEp_01==--\r\n" |
|
|
|
"\r\n"; |
|
|
|
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
TEST( MessageTest, Simple ) |
|
|
|
{ |
|
|
|
pEp::Message msg{PEP_dir_outgoing, "\r\n"}; |
|
|
|
pEp::Message msg{PEP_dir_outgoing, mail1_eml}; |
|
|
|
|
|
|
|
EXPECT_EQ(msg->dir, PEP_dir_outgoing); |
|
|
|
EXPECT_STREQ( msg->from->username, "Alice"); |
|
|
|
EXPECT_STREQ( msg->shortmsg, "Rødgrød med fløde" ); |
|
|
|
EXPECT_STREQ( msg->longmsg , "Rødgrød med fløde?\r\n" ); |
|
|
|
EXPECT_EQ( identity_list_length(msg->to), 1 ); |
|
|
|
EXPECT_EQ( identity_list_length(msg->cc), 4 ); |
|
|
|
EXPECT_EQ( identity_list_length(msg->bcc), 0 ); |
|
|
|
EXPECT_EQ( bloblist_length(msg->attachments), 4 ); |
|
|
|
} |
|
|
|