when opening an account by email address, such as during login attempts, and address is an alias, fail with proper error "no such credentials" instead of with error "no such account", which printing a stack trace

was encountered during smtp session. but could also happen for imapserver and
webmail.

in smtpserver, we now log error messages for smtp errors that cause us to print
a stack trace. would have made logging output more helpful (without having to
turn on trace-level logging).

hopefully solves issue #238 by mwyvr, thanks for reporting!
This commit is contained in:
Mechiel Lukkien
2024-11-10 23:13:38 +01:00
parent 0e338b0530
commit 3d4cd00430
3 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package smtpserver
import (
"errors"
"path/filepath"
"strings"
"testing"
@ -62,6 +63,12 @@ func TestAliasSubmitMsgFromDenied(t *testing.T) {
ts := newTestServer(t, filepath.FromSlash("../testdata/smtp/mox.conf"), dns.MockResolver{})
defer ts.close()
// Trying to open account by alias should result in proper error.
_, _, err := store.OpenEmail(pkglog, "public@mox.example")
if err == nil || !errors.Is(err, store.ErrUnknownCredentials) {
t.Fatalf("opening alias, got err %v, expected store.ErrUnknownCredentials", err)
}
acc, err := store.OpenAccount(pkglog, "☺")
tcheck(t, err, "open account")
err = acc.SetPassword(pkglog, password0)