diff --git a/tests/bdd_test.go b/tests/bdd_test.go index 8612369e..6ff7320f 100644 --- a/tests/bdd_test.go +++ b/tests/bdd_test.go @@ -171,6 +171,7 @@ func TestFeatures(testingT *testing.T) { ctx.Step(`^user "([^"]*)" connects IMAP client "([^"]*)" on port (\d+)$`, s.userConnectsIMAPClientOnPort) ctx.Step(`^user "([^"]*)" connects and authenticates IMAP client "([^"]*)"$`, s.userConnectsAndAuthenticatesIMAPClient) ctx.Step(`^user "([^"]*)" connects and authenticates IMAP client "([^"]*)" with address "([^"]*)"$`, s.userConnectsAndAuthenticatesIMAPClientWithAddress) + ctx.Step(`^user "([^"]*)" connects and can not authenticate IMAP client "([^"]*)" with address "([^"]*)"$`, s.userConnectsAndCanNotAuthenticateIMAPClientWithAddress) ctx.Step(`^IMAP client "([^"]*)" can authenticate$`, s.imapClientCanAuthenticate) ctx.Step(`^IMAP client "([^"]*)" can authenticate with address "([^"]*)"$`, s.imapClientCanAuthenticateWithAddress) ctx.Step(`^IMAP client "([^"]*)" cannot authenticate$`, s.imapClientCannotAuthenticate) diff --git a/tests/features/imap/auth.feature b/tests/features/imap/auth.feature index 375e047a..9adc36c6 100644 --- a/tests/features/imap/auth.feature +++ b/tests/features/imap/auth.feature @@ -1,8 +1,12 @@ Feature: A user can authenticate an IMAP client Background: Given there exists an account with username "[user:user]" and password "password" + And there exists an account with username "[user2:user2]" and password "password2" + And the account "[user:user]" has additional address "[alias:alias]@[domain]" + And the account "[user2:user2]" has additional disabled address "[alias2:alias2]@[domain]" And bridge starts And the user logs in with username "[user:user]" and password "password" + And the user logs in with username "[user2:user2]" and password "password2" Scenario: IMAP client can authenticate successfully When user "[user:user]" connects IMAP client "1" @@ -12,6 +16,12 @@ Feature: A user can authenticate an IMAP client When user "[user:user]" connects IMAP client "1" Then IMAP client "1" can authenticate with address "{toUpper:[user:user]@[domain]}" + Scenario: IMAP client can authenticate successfully with secondary address + Given user "[user:user]" connects and authenticates IMAP client "1" with address "[alias:alias]@[domain]" + + Scenario: IMAP client can not authenticate successfully with disable address + Given user "[user2:user2]" connects and can not authenticate IMAP client "1" with address "[alias2:alias2]@[domain]" + Scenario: IMAP client can authenticate successfully When user "[user:user]" connects IMAP client "1" Then IMAP client "1" can authenticate diff --git a/tests/imap_test.go b/tests/imap_test.go index 26a427a0..2f2cf448 100644 --- a/tests/imap_test.go +++ b/tests/imap_test.go @@ -59,6 +59,20 @@ func (s *scenario) userConnectsAndAuthenticatesIMAPClientWithAddress(username, c return client.Login(address, s.t.getUserBridgePass(userID)) } +func (s *scenario) userConnectsAndCanNotAuthenticateIMAPClientWithAddress(username, clientID, address string) error { + if err := s.t.newIMAPClient(s.t.getUserID(username), clientID); err != nil { + return err + } + + userID, client := s.t.getIMAPClient(clientID) + + if err := client.Login(address, s.t.getUserBridgePass(userID)); err == nil { + return fmt.Errorf("expected error, got nil") + } + + return nil +} + func (s *scenario) imapClientCanAuthenticate(clientID string) error { userID, client := s.t.getIMAPClient(clientID)