mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
test(GODT-2636): Add step for sending from EML
This commit is contained in:
@ -246,6 +246,7 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^SMTP client "([^"]*)" sends DATA:$`, s.smtpClientSendsData)
|
||||
ctx.Step(`^SMTP client "([^"]*)" sends RSET$`, s.smtpClientSendsReset)
|
||||
ctx.Step(`^SMTP client "([^"]*)" sends the following message from "([^"]*)" to "([^"]*)":$`, s.smtpClientSendsTheFollowingMessageFromTo)
|
||||
ctx.Step(`^SMTP client "([^"]*)" sends the following EML "([^"]*)" from "([^"]*)" to "([^"]*)"$`, s.smtpClientSendsTheFollowingEmlFromTo)
|
||||
ctx.Step(`^SMTP client "([^"]*)" logs out$`, s.smtpClientLogsOut)
|
||||
|
||||
// ==== TELEMETRY ====
|
||||
|
||||
@ -73,7 +73,7 @@ Feature: IMAP import messages
|
||||
|
||||
# The message is imported as UTF-8 and the content type is determined at build time.
|
||||
Scenario: Import message as latin1 without content type
|
||||
When IMAP client "1" appends "text_plain_unknown_latin1.eml" to "INBOX"
|
||||
When IMAP client "1" appends "plain/text_plain_unknown_latin1.eml" to "INBOX"
|
||||
Then it succeeds
|
||||
And IMAP client "1" eventually sees the following messages in "INBOX":
|
||||
| from | to | body |
|
||||
@ -81,7 +81,7 @@ Feature: IMAP import messages
|
||||
|
||||
# The message is imported and the body is converted to UTF-8.
|
||||
Scenario: Import message as latin1 with content type
|
||||
When IMAP client "1" appends "text_plain_latin1.eml" to "INBOX"
|
||||
When IMAP client "1" appends "plain/text_plain_latin1.eml" to "INBOX"
|
||||
Then it succeeds
|
||||
And IMAP client "1" eventually sees the following messages in "INBOX":
|
||||
| from | to | body |
|
||||
@ -89,7 +89,7 @@ Feature: IMAP import messages
|
||||
|
||||
# The message is imported anad the body is wrongly converted (body is corrupted).
|
||||
Scenario: Import message as latin1 with wrong content type
|
||||
When IMAP client "1" appends "text_plain_wrong_latin1.eml" to "INBOX"
|
||||
When IMAP client "1" appends "plain/text_plain_wrong_latin1.eml" to "INBOX"
|
||||
Then it succeeds
|
||||
And IMAP client "1" eventually sees the following messages in "INBOX":
|
||||
| from | to |
|
||||
|
||||
@ -343,3 +343,34 @@ Feature: SMTP sending of plain messages
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
Scenario: HTML message with Foreign/Nonascii chars in Subject and Body
|
||||
When there exists an account with username "bridgetest" and password "password"
|
||||
And the user logs in with username "bridgetest" and password "password"
|
||||
And user "bridgetest" connects and authenticates SMTP client "1"
|
||||
And SMTP client "1" sends the following EML "html/foreign_ascii_subject_body.eml" from "bridgetest@proton.local" to "pm.bridge.qa@gmail.com"
|
||||
Then it succeeds
|
||||
When user "bridgetest" connects and authenticates IMAP client "1"
|
||||
Then IMAP client "1" eventually sees the following messages in "Sent":
|
||||
| from | to | subject |
|
||||
| bridgetest@proton.local | pm.bridge.qa@gmail.com | Subjεέςτ ¶ Ä È |
|
||||
And the body in the "POST" request to "/mail/v4/messages" is:
|
||||
"""
|
||||
{
|
||||
"Message": {
|
||||
"Subject": "Subjεέςτ ¶ Ä È",
|
||||
"Sender": {
|
||||
"Name": "Bridge Test"
|
||||
},
|
||||
"ToList": [
|
||||
{
|
||||
"Address": "pm.bridge.qa@gmail.com",
|
||||
"Name": "External Bridge"
|
||||
}
|
||||
],
|
||||
"CCList": [],
|
||||
"BCCList": [],
|
||||
"MIMEType": "text/html"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
@ -193,3 +193,34 @@ Feature: SMTP sending of plain messages
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
Scenario: Basic message with multiple different attachments to internal account
|
||||
When there exists an account with username "bridgetest" and password "password"
|
||||
And the user logs in with username "bridgetest" and password "password"
|
||||
And user "bridgetest" connects and authenticates SMTP client "1"
|
||||
And SMTP client "1" sends the following EML "plain/text_plain_multiple_attachments.eml" from "bridgetest@proton.local" to "internalbridgetest@proton.local"
|
||||
Then it succeeds
|
||||
When user "bridgetest" connects and authenticates IMAP client "1"
|
||||
Then IMAP client "1" eventually sees the following messages in "Sent":
|
||||
| from | to | subject |
|
||||
| bridgetest@proton.local | internalbridgetest@proton.local | Plain with multiple different attachments |
|
||||
And the body in the "POST" request to "/mail/v4/messages" is:
|
||||
"""
|
||||
{
|
||||
"Message": {
|
||||
"Subject": "Plain with multiple different attachments",
|
||||
"Sender": {
|
||||
"Name": "Bridge Test"
|
||||
},
|
||||
"ToList": [
|
||||
{
|
||||
"Address": "internalbridgetest@proton.local",
|
||||
"Name": "Internal Bridge"
|
||||
}
|
||||
],
|
||||
"CCList": [],
|
||||
"BCCList": [],
|
||||
"MIMEType": "text/plain"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
@ -20,6 +20,8 @@ package tests
|
||||
import (
|
||||
"fmt"
|
||||
"net/smtp"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
|
||||
@ -132,28 +134,24 @@ func (s *scenario) smtpClientSendsReset(clientID string) error {
|
||||
func (s *scenario) smtpClientSendsTheFollowingMessageFromTo(clientID, from, to string, message *godog.DocString) error {
|
||||
_, client := s.t.getSMTPClient(clientID)
|
||||
|
||||
s.t.pushError(func() error {
|
||||
if err := client.Mail(from); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := clientSend(client, from, to, message.Content); err != nil {
|
||||
s.t.pushError(err)
|
||||
}
|
||||
|
||||
for _, to := range strings.Split(to, ", ") {
|
||||
if err := client.Rcpt(to); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
wc, err := client.Data()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (s *scenario) smtpClientSendsTheFollowingEmlFromTo(clientID, file, from, to string) error {
|
||||
_, client := s.t.getSMTPClient(clientID)
|
||||
|
||||
if _, err := wc.Write([]byte(message.Content)); err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join("testdata", file))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return wc.Close()
|
||||
}())
|
||||
if err := clientSend(client, from, to, string(b)); err != nil {
|
||||
s.t.pushError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -165,3 +163,26 @@ func (s *scenario) smtpClientLogsOut(clientID string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func clientSend(client *smtp.Client, from, to, message string) error {
|
||||
if err := client.Mail(from); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, to := range strings.Split(to, ", ") {
|
||||
if err := client.Rcpt(to); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
wc, err := client.Data()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := wc.Write([]byte(message)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return wc.Close()
|
||||
}
|
||||
|
||||
15
tests/testdata/html/foreign_ascii_subject_body.eml
vendored
Normal file
15
tests/testdata/html/foreign_ascii_subject_body.eml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
From: Bridge Test <bridgetest@proton.local>
|
||||
To: External Bridge <pm.bridge.qa@gmail.com>
|
||||
Subject: =?UTF-8?B?U3Vias61zq3Pgs+EIMK2IMOEIMOI?=
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
Subjεέςτ ¶ Ä È
|
||||
</body>
|
||||
</html>
|
||||
69
tests/testdata/plain/text_plain_multiple_attachments.eml
vendored
Normal file
69
tests/testdata/plain/text_plain_multiple_attachments.eml
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
From: Bridge Test <bridgetest@proton.local>
|
||||
To: Internal Bridge <internalbridgetest@proton.local>
|
||||
Subject: Plain with multiple different attachments
|
||||
Content-Type: multipart/mixed; boundary="bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606"
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: text/plain; charset=UTF-8; format=flowed
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
Body of plain text message with multiple attachments
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: application/zip; name="PINProtected.zip"
|
||||
Content-Disposition: attachment; filename="PINProtected.zip"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
UEsDBBQACAAIAHhlwVYAAAAAAAAAABADAAAMACAAbWVzc2FnZTIudHh0VVQNAAdkdnhk7nZ4
|
||||
AABQSwUGAAAAAAIAAgC/AAAAewMAAAAA
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; name="test.docx"
|
||||
Content-Disposition: attachment; filename="test.docx"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIo
|
||||
AAAAgB4AAHdvcmQvc3R5bGVzLnhtbFBLBQYAAAAACwALAMECAADXKQAAAAA=
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: application/pdf; name="test.pdf"
|
||||
Content-Disposition: attachment; filename="test.pdf"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
JVBERi0xLjUKJeLjz9MKNyAwIG9iago8PAovVHlwZSAvRm9udERlc2NyaXB0b3IKL0ZvbnRO
|
||||
MjM0NAolJUVPRgo=
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name="test.xlsx"
|
||||
Content-Disposition: attachment; filename="test.xlsx"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
UEsDBBQABgAIAAAAIQBi7p1oXgEAAJAEAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIo
|
||||
AAoACgCAAgAAexwAAAAA
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: text/xml; charset=UTF-8; name="testxml.xml"
|
||||
Content-Disposition: attachment; filename="testxml.xml"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHN1aXRl
|
||||
VUtUZXN0Ii8+CiAgICAgICAgPC9jbGFzc2VzPgogICAgPC90ZXN0PgoKPC9zdWl0ZT4=
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: text/plain; charset=UTF-8; name="update.txt"
|
||||
Content-Disposition: attachment; filename="update.txt"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
DQpHb2NlQERFU0tUT1AtQ0dONkZENiBNSU5HVzY0IC9jL1Byb2dyYW0gRmlsZXMvUHJvdG9u
|
||||
NFdqRUw5WkplbnJZcUZucXVvSFBEa0w5VWZFeTA0VlBYRkViVERWLVlQaS1BSWc9PSINCg==
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
|
||||
Content-Type: text/calendar; charset=UTF-8; name="=?UTF-8?B?6YCZ5piv5ryi5a2X55qE5LiA5YCL5L6L5a2QLmljcw==?="
|
||||
Content-Disposition: attachment; filename*0*=UTF-8''%E9%80%99%E6%98%AF%E6%BC%A2%E5%AD%97%E7%9A%84%E4%B8%80; filename*1*=%E5%80%8B%E4%BE%8B%E5%AD%90%2E%69%63%73
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
QkVHSU46VkNBTEVOREFSCk1FVEhPRDpQVUJMSVNIClZFUlNJT046Mi4wClgtV1ItQ0FMTkFN
|
||||
RDpWQUxBUk0KRU5EOlZFVkVOVApFTkQ6VkNBTEVOREFSCg==
|
||||
|
||||
--bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606--
|
||||
|
||||
Reference in New Issue
Block a user