Add testcase to verify that user is properly authenticated before sending mail if authenticator is setup

This commit is contained in:
Bernhard Froehlich 2020-05-26 19:11:01 +00:00
parent d345a27f9f
commit 44fcf08c5e
No known key found for this signature in database
GPG key ID: 4DD88C3F9F3B8333

View file

@ -318,6 +318,33 @@ func TestAuthNotSupported(t *testing.T) {
}
func TestAuthBypass(t *testing.T) {
addr, closer := runsslserver(t, &smtpd.Server{
Authenticator: func(peer smtpd.Peer, username, password string) error {
return smtpd.Error{Code: 550, Message: "Denied"}
},
ForceTLS: true,
ProtocolLogger: log.New(os.Stdout, "log: ", log.Lshortfile),
})
defer closer()
c, err := smtp.Dial(addr)
if err != nil {
t.Fatalf("Dial failed: %v", err)
}
if err := c.StartTLS(&tls.Config{InsecureSkipVerify: true}); err != nil {
t.Fatalf("STARTTLS failed: %v", err)
}
if err := c.Mail("sender@example.org"); err == nil {
t.Fatal("Unexpected MAIL success")
}
}
func TestConnectionCheck(t *testing.T) {
addr, closer := runserver(t, &smtpd.Server{