-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(GODT-2851): Determine Body MIMEType for all Multipart when import…
…ing to backend.
- Loading branch information
1 parent
0ee691e
commit e8aa47d
Showing
2 changed files
with
95 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ package proton_test | |
|
||
import ( | ||
"context" | ||
"github.com/ProtonMail/gluon/rfc822" | ||
"github.com/bradenaw/juniper/stream" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/ProtonMail/gluon/rfc822" | ||
"github.com/ProtonMail/go-proton-api" | ||
"github.com/ProtonMail/go-proton-api/server" | ||
"github.com/bradenaw/juniper/stream" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
|
@@ -89,14 +89,82 @@ func TestMessageImport_RelatedInlinePlaintext(t *testing.T) { | |
want rfc822.MIMEType | ||
}{ | ||
{ | ||
name: "RelatedInlinePlaintext", | ||
literal: "\"From: Nathaniel Borenstein <[email protected]>\\nTo: Ned Freed <[email protected]>\\nSubject: Sample message (import inline)\\nMIME-Version: 1.0\\nContent-type: multipart/related; boundary=\\\"BOUNDARY\\\"\\n\\n--BOUNDARY\\nContent-type: text/plain; charset=us-ascii\\n\\nHello world\\n--BOUNDARY\\nContent-Type: image/gif; name=\\\"email-action-left.gif\\\"\\nContent-Transfer-Encoding: base64\\nContent-ID: <[email protected]>\\nContent-Disposition: inline; filename=\\\"email-action-left.gif\\\"\\n\\nSGVsbG8gQXR0YWNobWVudA==\\n--BOUNDARY--\"", | ||
want: rfc822.TextPlain, | ||
name: "RelatedInlinePlaintext", | ||
literal: "From: Nathaniel Borenstein <[email protected]>\n" + | ||
"To: Ned Freed <[email protected]>\n" + | ||
"Subject: Sample message (import inline)\n" + | ||
"MIME-Version: 1.0\nContent-type: multipart/related; boundary=\"BOUNDARY\"\n\n" + | ||
"--BOUNDARY\nContent-type: text/plain; charset=us-ascii\n\n" + | ||
"Hello world\n" + | ||
"--BOUNDARY\n" + | ||
"Content-Type: image/gif; name=\"email-action-left.gif\"\n" + | ||
"Content-Transfer-Encoding: base64\n" + | ||
"Content-ID: <[email protected]>\n" + | ||
"Content-Disposition: inline; filename=\"email-action-left.gif\"\n\n" + | ||
"SGVsbG8gQXR0YWNobWVudA==\n" + | ||
"--BOUNDARY--", | ||
want: rfc822.TextPlain, | ||
}, | ||
{ | ||
name: "RelatedInlineHTML", | ||
literal: "From: Bridge Second Test <[email protected]>\n" + | ||
"To: Bridge Test <[email protected]>\n" + | ||
"Subject: Html Inline Importing\n" + | ||
"Content-Type: multipart/related; boundary=\"61FA22A41A3F46E8E90EF528\"\n\n" + | ||
"This is a multi-part message in MIME format.\n" + | ||
"--61FA22A41A3F46E8E90EF528\n" + | ||
"Content-Type: text/html; charset=utf-8\n" + | ||
"Content-Transfer-Encoding: 7bit\n\n" + | ||
"<html>\n<head>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n</head>\n" + | ||
"<body text=\"#000000\" bgcolor=\"#FFFFFF\">\n" + | ||
"<p><br>\n</p>\n<p>Behold! An inline <img moz-do-not-send=\"false\"\nsrc=\"cid:[email protected]\" alt=\"\"\nwidth=\"24\" height=\"24\"><br>\n</p>\n" + | ||
"</body>\n</html>\n\n" + | ||
"--61FA22A41A3F46E8E90EF528\n" + | ||
"Content-Type: image/gif; name=\"email-action-left.gif\"\n" + | ||
"Content-Transfer-Encoding: base64\nContent-ID: <[email protected]>\n" + | ||
"Content-Disposition: inline; filename=\"email-action-left.gif\"\n\n" + | ||
"R0lGODlhGAAYANUAACcsKOHs4kppTH6tgYWxiIq0jTVENpG5lDI/M7bRuEaJSkqOTk2RUU+P\nU16lYl+lY2iva262cXS6d3rDfYLNhWeeamKTZGSVZkNbRGqhbOPt4////+7u7qioqFZWVlNT\nUyIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAG\n/8CNcLjRJAqVRqNSSGiI0GFgoKhar4NAdHioMhyRCYUyiTgY1cOWUH1ILgIDAGAQXCSPKgHa\nXUAyGCCCg4IYGRALCmpCAVUQFgiEkiAIFhBVWhtUDxmRk5IIGXkDRQoMEoGfHpIYEmhGCg4X\nnyAdHB+SFw4KRwoRArQdG7eEAhEKSAoTBoIdzs/Cw7iCBhMKSQoUAIJbQ8QgABQKStnbIN1C\n3+HjFcrMtdDO6dMg1dcFvsCfwt+CxsgJYs3a10+QLl4aTKGitYpQq1eaFHDyREtQqFGMHEGq\nSMkSJi4K/ACiZQiRIihsJL6JM6fOnTwK9kTpYgqMGDJm0JzsNuWKTw0FWdANMYJECRMnW4IA\nADs=\n\n" + | ||
"--61FA22A41A3F46E8E90EF528--", | ||
want: rfc822.TextHTML, | ||
}, | ||
{ | ||
name: "Multipart/mixed single part plain", | ||
literal: "From: Nathaniel Borenstein <[email protected]>\n" + | ||
"To: Ned Freed <[email protected]>\n" + | ||
"Subject: Sample message (import inline)\n" + | ||
"MIME-Version: 1.0\nContent-type: multipart/mixed; boundary=\"BOUNDARY\"\n\n" + | ||
"--BOUNDARY\nContent-type: text/plain; charset=us-ascii\n\n" + | ||
"Hello world\n" + | ||
"--BOUNDARY\n" + | ||
"Content-Type: image/gif; name=\"email-action-left.gif\"\n" + | ||
"Content-Transfer-Encoding: base64\n" + | ||
"Content-ID: <[email protected]>\n" + | ||
"Content-Disposition: inline; filename=\"email-action-left.gif\"\n\n" + | ||
"SGVsbG8gQXR0YWNobWVudA==\n" + | ||
"--BOUNDARY--", | ||
want: rfc822.TextPlain, | ||
}, | ||
{ | ||
name: "RelatedInlineHTML", | ||
literal: "Date: 01 Jan 1980 00:00:00 +0000\nFrom: Bridge Second Test <[email protected]>\nTo: Bridge Test <[email protected]>\nSubject: Html Inline Importing\nContent-Disposition: inline\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0\nMIME-Version: 1.0\nContent-Language: en-US\nContent-Type: multipart/related; boundary=\"61FA22A41A3F46E8E90EF528\"\n\nThis is a multi-part message in MIME format.\n--61FA22A41A3F46E8E90EF528\nContent-Type: text/html; charset=utf-8\nContent-Transfer-Encoding: 7bit\n\n<html>\n<head>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n</head>\n<body text=\"#000000\" bgcolor=\"#FFFFFF\">\n<p><br>\n</p>\n<p>Behold! An inline <img moz-do-not-send=\"false\"\nsrc=\"cid:[email protected]\" alt=\"\"\nwidth=\"24\" height=\"24\"><br>\n</p>\n</body>\n</html>\n\n--61FA22A41A3F46E8E90EF528\nContent-Type: image/gif; name=\"email-action-left.gif\"\nContent-Transfer-Encoding: base64\nContent-ID: <[email protected]>\nContent-Disposition: inline; filename=\"email-action-left.gif\"\n\nR0lGODlhGAAYANUAACcsKOHs4kppTH6tgYWxiIq0jTVENpG5lDI/M7bRuEaJSkqOTk2RUU+P\nU16lYl+lY2iva262cXS6d3rDfYLNhWeeamKTZGSVZkNbRGqhbOPt4////+7u7qioqFZWVlNT\nUyIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAG\n/8CNcLjRJAqVRqNSSGiI0GFgoKhar4NAdHioMhyRCYUyiTgY1cOWUH1ILgIDAGAQXCSPKgHa\nXUAyGCCCg4IYGRALCmpCAVUQFgiEkiAIFhBVWhtUDxmRk5IIGXkDRQoMEoGfHpIYEmhGCg4X\nnyAdHB+SFw4KRwoRArQdG7eEAhEKSAoTBoIdzs/Cw7iCBhMKSQoUAIJbQ8QgABQKStnbIN1C\n3+HjFcrMtdDO6dMg1dcFvsCfwt+CxsgJYs3a10+QLl4aTKGitYpQq1eaFHDyREtQqFGMHEGq\nSMkSJi4K/ACiZQiRIihsJL6JM6fOnTwK9kTpYgqMGDJm0JzsNuWKTw0FWdANMYJECRMnW4IA\nADs=\n\n--61FA22A41A3F46E8E90EF528--", | ||
want: rfc822.TextHTML, | ||
name: "Multipart/mixed single part HTML", | ||
literal: "From: Bridge Second Test <[email protected]>\n" + | ||
"To: Bridge Test <[email protected]>\n" + | ||
"Subject: Html Inline Importing\n" + | ||
"Content-Type: multipart/mixed; boundary=\"61FA22A41A3F46E8E90EF528\"\n\n" + | ||
"This is a multi-part message in MIME format.\n" + | ||
"--61FA22A41A3F46E8E90EF528\n" + | ||
"Content-Type: text/html; charset=utf-8\n" + | ||
"Content-Transfer-Encoding: 7bit\n\n" + | ||
"<html>\n<head>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n</head>\n" + | ||
"<body text=\"#000000\" bgcolor=\"#FFFFFF\">\n" + | ||
"<p><br>\n</p>\n<p>Behold! An inline <img moz-do-not-send=\"false\"\nsrc=\"cid:[email protected]\" alt=\"\"\nwidth=\"24\" height=\"24\"><br>\n</p>\n" + | ||
"</body>\n</html>\n\n" + | ||
"--61FA22A41A3F46E8E90EF528\n" + | ||
"Content-Type: image/gif; name=\"email-action-left.gif\"\n" + | ||
"Content-Transfer-Encoding: base64\nContent-ID: <[email protected]>\n" + | ||
"Content-Disposition: inline; filename=\"email-action-left.gif\"\n\n" + | ||
"R0lGODlhGAAYANUAACcsKOHs4kppTH6tgYWxiIq0jTVENpG5lDI/M7bRuEaJSkqOTk2RUU+P\nU16lYl+lY2iva262cXS6d3rDfYLNhWeeamKTZGSVZkNbRGqhbOPt4////+7u7qioqFZWVlNT\nUyIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAG\n/8CNcLjRJAqVRqNSSGiI0GFgoKhar4NAdHioMhyRCYUyiTgY1cOWUH1ILgIDAGAQXCSPKgHa\nXUAyGCCCg4IYGRALCmpCAVUQFgiEkiAIFhBVWhtUDxmRk5IIGXkDRQoMEoGfHpIYEmhGCg4X\nnyAdHB+SFw4KRwoRArQdG7eEAhEKSAoTBoIdzs/Cw7iCBhMKSQoUAIJbQ8QgABQKStnbIN1C\n3+HjFcrMtdDO6dMg1dcFvsCfwt+CxsgJYs3a10+QLl4aTKGitYpQq1eaFHDyREtQqFGMHEGq\nSMkSJi4K/ACiZQiRIihsJL6JM6fOnTwK9kTpYgqMGDJm0JzsNuWKTw0FWdANMYJECRMnW4IA\nADs=\n\n" + | ||
"--61FA22A41A3F46E8E90EF528--", | ||
want: rfc822.TextHTML, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters