mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-23 10:26:44 +00:00
Upgrade to latest go-smtp
This commit is contained in:
@ -1,29 +1,29 @@
|
||||
Feature: SMTP auth
|
||||
Scenario: Ask EHLO
|
||||
Given there is connected user "user"
|
||||
When SMTP client sends EHLO
|
||||
When SMTP client sends "EHLO example.com"
|
||||
Then SMTP response is "OK"
|
||||
|
||||
Scenario: Authenticates successfully and EHLO successfully
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends EHLO
|
||||
When SMTP client sends "EHLO example.com"
|
||||
Then SMTP response is "OK"
|
||||
|
||||
Scenario: Authenticates with bad password
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user" with bad password
|
||||
Then SMTP response is "SMTP error: 454 backend/credentials: incorrect password"
|
||||
Then SMTP response is "SMTP error: 454 4.7.0 backend/credentials: incorrect password"
|
||||
|
||||
Scenario: Authenticates with disconnected user
|
||||
Given there is disconnected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "SMTP error: 454 account is logged out, use the app to login again"
|
||||
Then SMTP response is "SMTP error: 454 4.7.0 account is logged out, use the app to login again"
|
||||
|
||||
Scenario: Authenticates with no user
|
||||
When SMTP client authenticates with username "user@pm.me" and password "bridgepassword"
|
||||
Then SMTP response is "SMTP error: 454 user user@pm.me not found"
|
||||
Then SMTP response is "SMTP error: 454 4.7.0 user user@pm.me not found"
|
||||
|
||||
Scenario: Authenticates with capital letter
|
||||
Given there is connected user "userAddressWithCapitalLetter"
|
||||
@ -43,7 +43,7 @@ Feature: SMTP auth
|
||||
Scenario: Authenticates with more addresses - disabled address
|
||||
Given there is connected user "userMoreAddresses"
|
||||
When SMTP client authenticates "userMoreAddresses" with address "disabled"
|
||||
Then SMTP response is "SMTP error: 454 user .* not found"
|
||||
Then SMTP response is "SMTP error: 454 4.7.0 user .* not found"
|
||||
|
||||
@ignore-live
|
||||
Scenario: Authenticates with secondary address of account with disabled primary address
|
||||
|
||||
83
test/features/bridge/smtp/init.feature
Normal file
83
test/features/bridge/smtp/init.feature
Normal file
@ -0,0 +1,83 @@
|
||||
Feature: SMTP initiation
|
||||
Scenario: Empty FROM
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "MAIL FROM:<>"
|
||||
Then SMTP response is "OK"
|
||||
|
||||
Scenario: Send without FROM and TO
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "DATA"
|
||||
Then SMTP response is "SMTP error: 502 5.5.1 Missing RCPT TO command."
|
||||
|
||||
Scenario: Reset is the same as without FROM and 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>"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "RCPT TO:<user@pm.me>"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "RSET"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "DATA"
|
||||
Then SMTP response is "SMTP error: 502 5.5.1 Missing RCPT TO command"
|
||||
|
||||
Scenario: Send without FROM
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "RCPT TO:<user@pm.me>"
|
||||
Then SMTP response is "SMTP error: 502 5.5.1 Missing MAIL FROM command."
|
||||
|
||||
Scenario: Send without 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>"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "DATA"
|
||||
Then SMTP response is "SMTP error: 502 5.5.1 Missing RCPT TO command."
|
||||
|
||||
Scenario: Send with empty FROM
|
||||
Given there is connected user "user"
|
||||
When SMTP client authenticates "user"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "MAIL FROM:<>"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "RCPT TO:<user@pm.me>"
|
||||
Then SMTP response is "OK"
|
||||
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"
|
||||
|
||||
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>"
|
||||
Then SMTP response is "OK"
|
||||
When SMTP client sends "RCPT TO:<>"
|
||||
Then SMTP response is "OK"
|
||||
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 recipient"
|
||||
|
||||
Scenario: Allow BODY 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> 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=<>"
|
||||
Then SMTP response is "OK"
|
||||
@ -38,4 +38,4 @@ Feature: SMTP wrong messages
|
||||
|
||||
|
||||
"""
|
||||
Then SMTP response is "SMTP error: 554 Error: transaction failed, blame it on the weather: failed to create new parser: unexpected EOF"
|
||||
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"
|
||||
|
||||
@ -33,10 +33,10 @@ func SMTPActionsAuthFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^SMTP client authenticates with username "([^"]*)" and password "([^"]*)"$`, smtpClientAuthenticatesWithUsernameAndPassword)
|
||||
s.Step(`^SMTP client logs out$`, smtpClientLogsOut)
|
||||
s.Step(`^SMTP client sends message$`, smtpClientSendsMessage)
|
||||
s.Step(`^SMTP client sends EHLO$`, smtpClientSendsEHLO)
|
||||
s.Step(`^SMTP client "([^"]*)" sends message$`, smtpClientNamedSendsMessage)
|
||||
s.Step(`^SMTP client sends message with bcc "([^"]*)"$`, smtpClientSendsMessageWithBCC)
|
||||
s.Step(`^SMTP client "([^"]*)" sends message with bcc "([^"]*)"$`, smtpClientNamedSendsMessageWithBCC)
|
||||
s.Step(`^SMTP client sends "([^"]*)"$`, smtpClientSendsCommand)
|
||||
}
|
||||
|
||||
func smtpClientAuthenticates(bddUserID string) error {
|
||||
@ -93,12 +93,6 @@ func smtpClientSendsMessage(message *gherkin.DocString) error {
|
||||
return smtpClientNamedSendsMessage("smtp", message)
|
||||
}
|
||||
|
||||
func smtpClientSendsEHLO() error {
|
||||
res := ctx.GetSMTPClient("smtp").SendCommands("EHLO ateist.test")
|
||||
ctx.SetSMTPLastResponse("smtp", res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func smtpClientNamedSendsMessage(clientID string, message *gherkin.DocString) error {
|
||||
return smtpClientNamedSendsMessageWithBCC(clientID, "", message)
|
||||
}
|
||||
@ -112,3 +106,11 @@ func smtpClientNamedSendsMessageWithBCC(clientID, bcc string, message *gherkin.D
|
||||
ctx.SetSMTPLastResponse(clientID, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func smtpClientSendsCommand(command string) error {
|
||||
command = strings.ReplaceAll(command, "\\r", "\r")
|
||||
command = strings.ReplaceAll(command, "\\n", "\n")
|
||||
res := ctx.GetSMTPClient("smtp").SendCommands(command)
|
||||
ctx.SetSMTPLastResponse("smtp", res)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user