Other: Match any case in IMAP/SMTP auth, with test

This commit is contained in:
James Houlahan
2022-10-13 11:02:43 +02:00
parent 23d3e54ddb
commit 7fe2c094a9
4 changed files with 17 additions and 2 deletions

View File

@ -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
}
}

View File

@ -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)

View File

@ -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

View File

@ -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)