mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
Other: Match any case in IMAP/SMTP auth, with test
This commit is contained in:
@ -375,7 +375,7 @@ func (user *User) checkAuth(email string, password []byte) (string, error) {
|
||||
|
||||
return safe.MapValuesRetErr(user.apiAddrs, func(apiAddrs []liteapi.Address) (string, error) {
|
||||
for _, addr := range apiAddrs {
|
||||
if addr.Email == strings.ToLower(email) {
|
||||
if strings.EqualFold(addr.Email, strings.ToLower(email)) {
|
||||
return addr.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +140,7 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^user "([^"]*)" connects and authenticates IMAP client "([^"]*)"$`, s.userConnectsAndAuthenticatesIMAPClient)
|
||||
ctx.Step(`^user "([^"]*)" connects and authenticates IMAP client "([^"]*)" with address "([^"]*)"$`, s.userConnectsAndAuthenticatesIMAPClientWithAddress)
|
||||
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)
|
||||
ctx.Step(`^IMAP client "([^"]*)" cannot authenticate with address "([^"]*)"$`, s.imapClientCannotAuthenticateWithAddress)
|
||||
ctx.Step(`^IMAP client "([^"]*)" cannot authenticate with incorrect username$`, s.imapClientCannotAuthenticateWithIncorrectUsername)
|
||||
|
||||
@ -8,6 +8,14 @@ Feature: A user can authenticate an IMAP client
|
||||
When user "user@pm.me" connects IMAP client "1"
|
||||
Then IMAP client "1" can authenticate
|
||||
|
||||
Scenario: IMAP client can authenticate successfully with different case
|
||||
When user "user@pm.me" connects IMAP client "1"
|
||||
Then IMAP client "1" can authenticate with address "USER@PM.ME"
|
||||
|
||||
Scenario: IMAP client can authenticate successfully
|
||||
When user "user@pm.me" connects IMAP client "1"
|
||||
Then IMAP client "1" can authenticate
|
||||
|
||||
Scenario: IMAP client cannot authenticate with bad username
|
||||
When user "user@pm.me" connects IMAP client "1"
|
||||
Then IMAP client "1" cannot authenticate with incorrect username
|
||||
|
||||
@ -45,6 +45,12 @@ func (s *scenario) imapClientCanAuthenticate(clientID string) error {
|
||||
return client.Login(s.t.getUserAddrs(userID)[0], s.t.getUserBridgePass(userID))
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientCanAuthenticateWithAddress(clientID string, address string) error {
|
||||
userID, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
return client.Login(address, s.t.getUserBridgePass(userID))
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientCannotAuthenticate(clientID string) error {
|
||||
userID, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user