diff --git a/tests/bdd_test.go b/tests/bdd_test.go index d5f8ffd8..d9c5f36b 100644 --- a/tests/bdd_test.go +++ b/tests/bdd_test.go @@ -24,13 +24,24 @@ import ( "testing" "time" + "github.com/ProtonMail/proton-bridge/v2/internal/certs" "github.com/ProtonMail/proton-bridge/v2/internal/user" "github.com/cucumber/godog" "github.com/stretchr/testify/require" + "gitlab.protontech.ch/go/liteapi/server/account" ) func init() { + // Use the fast key generation for tests. + account.GenerateKey = FastGenerateKey + + // Use the fast cert generation for tests. + certs.GenerateCert = FastGenerateCert + + // Set the event period to 100 milliseconds for more responsive tests. user.DefaultEventPeriod = 100 * time.Millisecond + + // Don't use jitter during tests. user.DefaultEventJitter = 0 } diff --git a/tests/features/smtp/send/html.feature b/tests/features/smtp/send/html.feature index 75483d2e..06e3400d 100644 --- a/tests/features/smtp/send/html.feature +++ b/tests/features/smtp/send/html.feature @@ -2,7 +2,6 @@ Feature: SMTP sending of plain messages Background: Given there exists an account with username "user@pm.me" and password "password" And there exists an account with username "bridgetest@protonmail.com" and password "password" - And there exists an account with username "bridgetest2@protonmail.com" and password "password" And bridge starts And the user logs in with username "user@pm.me" and password "password" And user "user@pm.me" connects and authenticates SMTP client "1" diff --git a/tests/features/smtp/send/html_att.feature b/tests/features/smtp/send/html_att.feature index 10a028af..2599f30e 100644 --- a/tests/features/smtp/send/html_att.feature +++ b/tests/features/smtp/send/html_att.feature @@ -2,7 +2,6 @@ Feature: SMTP sending of plain messages Background: Given there exists an account with username "user@pm.me" and password "password" And there exists an account with username "bridgetest@protonmail.com" and password "password" - And there exists an account with username "bridgetest2@protonmail.com" and password "password" And bridge starts And the user logs in with username "user@pm.me" and password "password" And user "user@pm.me" connects and authenticates SMTP client "1" diff --git a/tests/features/smtp/send/two_messages.feature b/tests/features/smtp/send/two_messages.feature new file mode 100644 index 00000000..d7384e11 --- /dev/null +++ b/tests/features/smtp/send/two_messages.feature @@ -0,0 +1,75 @@ +Feature: SMTP sending two messages + Background: + Given there exists an account with username "user@pm.me" and password "password" + And there exists an account with username "user-multi@pm.me" and password "password" + And the account "user-multi@pm.me" has additional address "user-multi-alias@pm.me" + And there exists an account with username "bridgetest@protonmail.com" and password "password" + And bridge starts + And the user logs in with username "user@pm.me" and password "password" + And the user logs in with username "user-multi@pm.me" and password "password" + And the user sets the address mode of "user-multi@pm.me" to "split" + + Scenario: Send two messages in one connection + When user "user@pm.me" connects and authenticates SMTP client "1" + And SMTP client "1" sends the following message from "user@pm.me" to "bridgetest@protonmail.com": + """ + From: Bridge Test + To: Internal Bridge + + hello + + """ + Then it succeeds + When SMTP client "1" sends the following message from "user@pm.me" to "bridgetest@protonmail.com": + """ + From: Bridge Test + To: Internal Bridge + + world + + """ + Then it succeeds + + Scenario: Send with two addresses of the same user in split mode + When user "user-multi@pm.me" connects and authenticates SMTP client "1" with address "user-multi@pm.me" + And user "user-multi@pm.me" connects and authenticates SMTP client "2" with address "user-multi-alias@pm.me" + And SMTP client "1" sends the following message from "user-multi@pm.me" to "bridgetest@protonmail.com>": + """ + From: Bridge Test + To: Internal Bridge + + hello + + """ + Then it succeeds + When SMTP client "2" sends the following message from "user-multi@pm.me" to "bridgetest@protonmail.com>": + """ + From: Bridge Test + To: Internal Bridge + + world + + """ + Then it succeeds + + Scenario: Send with two separate users + When user "user@pm.me" connects and authenticates SMTP client "1" + And user "user-multi@pm.me" connects and authenticates SMTP client "2" + When SMTP client "1" sends the following message from "user@pm.me" to "bridgetest@protonmail.com>": + """ + From: Bridge Test + To: Internal Bridge + + hello + + """ + Then it succeeds + When SMTP client "2" sends the following message from "user-multi@pm.me" to "bridgetest@protonmail.com>": + """ + From: Bridge Test + To: Internal Bridge + + world + + """ + Then it succeeds diff --git a/tests/init_test.go b/tests/init_test.go deleted file mode 100644 index 6f6acd68..00000000 --- a/tests/init_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package tests - -import ( - "github.com/ProtonMail/proton-bridge/v2/internal/certs" - "gitlab.protontech.ch/go/liteapi/server/account" -) - -func init() { - // Use the fast key generation for tests. - account.GenerateKey = FastGenerateKey - - // Use the fast cert generation for tests. - certs.GenerateCert = FastGenerateCert -}