summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDamien Caliste <dcaliste@free.fr>2018-12-03 13:44:53 +0100
committerDamien Caliste <dcaliste@free.fr>2018-12-18 11:54:16 +0000
commit03bdfab415b9e88165c0e2bad3d97eb0976d4a63 (patch)
tree94ba9fc0ba9adef184373c47d9a6588fe8f09de8 /tests
parent3dc8e6f79caf1c8c108700be0f03df914e97821e (diff)
Also generate boundaries when serializing QMailMessagePart
In a multipart messages, boundaries are generated when calling QMailMessage::toRfc2822(). For signature purposes, there is a need to generate RFC2822 compliant output for QMailMessagePart only. Previous implementation of QMailMessagePart::toRfc2822() introduced for signature purposes was lacking boundary generation. Change-Id: I7381cf2cb3a8bf83267f36e2f3f7369e8b040cef Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp b/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp
index e3cf690e..ed6a6510 100644
--- a/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp
+++ b/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp
@@ -86,6 +86,7 @@ private slots:
void appendHeaderField();
void removeHeaderField();
+ void testToRfc2822();
void testSerialization();
};
@@ -340,6 +341,55 @@ void tst_QMailMessagePart::removeHeaderField()
QCOMPARE(m.headerFields("Resent-From"), QList<QMailMessageHeaderField>());
}
+void tst_QMailMessagePart::testToRfc2822()
+{
+ QMailMessagePart body = QMailMessagePart::fromData
+ (QStringLiteral("Some body text"),
+ QMailMessageContentDisposition(),
+ QMailMessageContentType("text/plain"),
+ QMailMessageBody::QuotedPrintable);
+ QMailMessagePart disposition = QMailMessagePart::fromData
+ (QByteArray(),
+ QMailMessageContentDisposition(),
+ QMailMessageContentType("message/disposition-notification"),
+ QMailMessageBody::NoEncoding);
+ disposition.setHeaderField("Original-Recipient", "foo@example.org");
+ disposition.setHeaderField("Original-Message-ID", "123456789");
+
+ QMailMessagePart alt = QMailMessagePart::fromData
+ (QByteArray(),
+ QMailMessageContentDisposition(),
+ QMailMessageContentType(),
+ QMailMessageBodyFwd::NoEncoding);
+ alt.setMultipartType(QMailMessagePartContainer::MultipartAlternative);
+ alt.appendPart(body);
+ alt.appendPart(disposition);
+
+ const QByteArray expected(
+"Content-Type: multipart/alternative; boundary=\"[}<}]\"" CRLF
+"Content-Disposition:" CRLF
+CRLF
+CRLF
+"--[}<}]" CRLF
+"Content-Type: text/plain" CRLF
+"Content-Transfer-Encoding: quoted-printable" CRLF
+"Content-Disposition:" CRLF
+CRLF
+"Some body text" CRLF
+"--[}<}]" CRLF
+"Content-Type: message/disposition-notification" CRLF
+"Content-Disposition:" CRLF
+"Original-Recipient: foo@example.org" CRLF
+"Original-Message-ID: 123456789" CRLF
+CRLF
+CRLF
+"--[}<}]--" CRLF
+);
+
+ const QByteArray serialized = alt.toRfc2822();
+ QCOMPARE( serialized, expected );
+}
+
void tst_QMailMessagePart::testSerialization()
{
QByteArray data;