Prefer From header instead of MAIL FROM address

This commit is contained in:
Michal Horejsek
2020-12-16 11:17:00 +01:00
parent 2a0052dda6
commit 7b112fc448
17 changed files with 179 additions and 110 deletions

View File

@ -211,7 +211,7 @@ func (api *FakePMAPI) Import(importMessageRequests []*pmapi.ImportMsgReq) ([]*pm
}
func (api *FakePMAPI) generateMessageFromImportRequest(msgReq *pmapi.ImportMsgReq) (*pmapi.Message, error) {
m, _, _, _, err := message.Parse(bytes.NewReader(msgReq.Body), "", "") // nolint[dogsled]
m, _, _, _, err := message.Parse(bytes.NewReader(msgReq.Body)) // nolint[dogsled]
if err != nil {
return nil, err
}

View File

@ -17,7 +17,7 @@ Feature: SMTP initiation
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.me>"
When SMTP client sends "MAIL FROM:<[userAddress]>"
Then SMTP response is "OK"
When SMTP client sends "RCPT TO:<user@pm.me>"
Then SMTP response is "OK"
@ -37,7 +37,7 @@ Feature: SMTP initiation
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.me>"
When SMTP client sends "MAIL FROM:<[userAddress]>"
Then SMTP response is "OK"
When SMTP client sends "DATA"
Then SMTP response is "SMTP error: 502 5.5.1 Missing RCPT TO command."
@ -53,13 +53,13 @@ Feature: SMTP initiation
When SMTP client sends "DATA"
Then SMTP response is "OK"
When SMTP client sends "hello\r\n."
Then SMTP response is "SMTP error: 554 5.0.0 Error: transaction failed, blame it on the weather: missing sender"
Then SMTP response is "SMTP error: 554 5.0.0 Error: transaction failed, blame it on the weather: missing return path"
Scenario: Send with empty TO
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.me>"
When SMTP client sends "MAIL FROM:<[userAddress]>"
Then SMTP response is "OK"
When SMTP client sends "RCPT TO:<>"
Then SMTP response is "OK"
@ -72,12 +72,19 @@ Feature: SMTP initiation
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.me> BODY=7BIT"
When SMTP client sends "MAIL FROM:<[userAddress]> BODY=7BIT"
Then SMTP response is "OK"
Scenario: Allow AUTH parameter of MAIL FROM command
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.me> AUTH=<>"
When SMTP client sends "MAIL FROM:<[userAddress]> AUTH=<>"
Then SMTP response is "OK"
Scenario: FROM not owned by user
Given there is connected user "user"
When SMTP client authenticates "user"
Then SMTP response is "OK"
When SMTP client sends "MAIL FROM:<user@pm.test>"
Then SMTP response is "SMTP error: 451 4.0.0 backend: invalid return path: not owned by user"

View File

@ -7,7 +7,7 @@ Feature: SMTP with bcc
When SMTP client sends message with bcc "bridgetest2@protonmail.com"
"""
Subject: hello
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
hello
@ -43,7 +43,7 @@ Feature: SMTP with bcc
When SMTP client sends message with bcc "bridgetest@protonmail.com"
"""
Subject: hello
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
hello

View File

@ -6,7 +6,7 @@ Feature: SMTP wrong messages
Scenario: Message with attachment and wrong boundaries
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: With attachment (wrong boundaries)
Content-Type: multipart/related; boundary=bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
@ -39,3 +39,14 @@ Feature: SMTP wrong messages
"""
Then SMTP response is "SMTP error: 554 5.0.0 Error: transaction failed, blame it on the weather: failed to create new parser: unexpected EOF"
Scenario: Invalid from
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
hello
"""
Then SMTP response is "SMTP error: 554 5.0.0 Error: transaction failed, blame it on the weather: backend: invalid email address: not owned by user"

View File

@ -6,7 +6,7 @@ Feature: SMTP sending of HTML messages
Scenario: HTML message to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: HTML text external
Content-Disposition: inline
@ -45,7 +45,7 @@ Feature: SMTP sending of HTML messages
Scenario: HTML message with inline image to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Html Inline External
Content-Disposition: inline
@ -120,7 +120,7 @@ Feature: SMTP sending of HTML messages
Scenario: HTML message with alternative inline to internal account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Html Inline Alternative Internal
Content-Disposition: inline
@ -209,7 +209,7 @@ Feature: SMTP sending of HTML messages
Scenario: HTML message with alternative inline to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Html Inline Alternative External
Content-Disposition: inline

View File

@ -6,7 +6,7 @@ Feature: SMTP sending of HTML messages with attachments
Scenario: HTML message with attachment to internal account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: HTML with attachment internal
Content-Type: multipart/related; boundary=bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
@ -65,7 +65,7 @@ Feature: SMTP sending of HTML messages with attachments
Scenario: HTML message with attachment to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: HTML with attachment external PGP
Content-Type: multipart/mixed; boundary=bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606

View File

@ -6,7 +6,7 @@ Feature: SMTP sending of plain messages
Scenario: Only from and to headers to internal account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
hello
@ -40,7 +40,7 @@ Feature: SMTP sending of plain messages
Scenario: Only from and to headers to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
hello
@ -74,7 +74,7 @@ Feature: SMTP sending of plain messages
Scenario: Basic message to internal account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Plain text internal
Content-Disposition: inline
@ -111,7 +111,7 @@ Feature: SMTP sending of plain messages
Scenario: Basic message to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Plain text external
Content-Disposition: inline
@ -148,7 +148,7 @@ Feature: SMTP sending of plain messages
Scenario: Message without charset is utf8
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Plain text no charset external
Content-Disposition: inline
@ -185,7 +185,7 @@ Feature: SMTP sending of plain messages
Scenario: Message without charset is base64-encoded latin1
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Plain text no charset external
Content-Disposition: inline
@ -225,7 +225,7 @@ Feature: SMTP sending of plain messages
Scenario: Message without charset and content is detected as HTML
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Plain, no charset, no content, external
Content-Disposition: inline

View File

@ -6,7 +6,7 @@ Feature: SMTP sending of plain messages with attachments
Scenario: Basic message with attachment to internal account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Plain with attachment
Content-Type: multipart/related; boundary=bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
@ -65,7 +65,7 @@ Feature: SMTP sending of plain messages with attachments
Scenario: Plain message with attachment to external account
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge <pm.bridge.qa@gmail.com>
Subject: Plain with attachment external
Content-Type: multipart/related; boundary=bc5bd30245232f31b6c976adcd59bb0069c9b13f986f9e40c2571bb80aa16606
@ -124,7 +124,7 @@ Feature: SMTP sending of plain messages with attachments
Scenario: Plain message with attachment to two external accounts
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: External Bridge 1 <pm.bridge.qa@gmail.com>
CC: External Bridge 2 <bridgeqa@seznam.cz>
Subject: Plain with attachment external PGP and external CC

View File

@ -4,7 +4,7 @@ Feature: SMTP sending the same message twice
And there is SMTP client logged in as "user"
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Hello
@ -16,7 +16,7 @@ Feature: SMTP sending the same message twice
Scenario: The exact same message is not sent twice
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Hello
@ -31,7 +31,7 @@ Feature: SMTP sending the same message twice
Scenario: Slight change means different message and is sent twice
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Hello.

View File

@ -4,7 +4,7 @@ Feature: SMTP sending two messages
And there is SMTP client logged in as "user"
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
hello
@ -13,7 +13,7 @@ Feature: SMTP sending two messages
Then SMTP response is "OK"
When SMTP client sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
world
@ -28,7 +28,7 @@ Feature: SMTP sending two messages
And there is SMTP client "smtp2" logged in as "userMoreAddresses" with address "secondary"
When SMTP client "smtp1" sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
hello
@ -37,7 +37,7 @@ Feature: SMTP sending two messages
Then SMTP response to "smtp1" is "OK"
When SMTP client "smtp2" sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
world
@ -53,7 +53,7 @@ Feature: SMTP sending two messages
When SMTP client "smtp1" sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
hello
@ -62,7 +62,7 @@ Feature: SMTP sending two messages
Then SMTP response to "smtp1" is "OK"
When SMTP client "smtp2" sends message
"""
From: Bridge Test <bridgetest@pm.test>
From: Bridge Test <[userAddress]>
To: Internal Bridge <bridgetest@protonmail.com>
world

View File

@ -74,6 +74,8 @@ func (c *SMTPClient) SendCommands(commands ...string) *SMTPResponse {
smtpResponse := &SMTPResponse{t: c.t}
for _, command := range commands {
command = strings.ReplaceAll(command, "[userAddress]", c.address)
tstart := time.Now()
c.debug.printReq(command)