Add testcase to verify that user is properly authenticated before sending mail if authenticator is setup
This commit is contained in:
parent
d345a27f9f
commit
44fcf08c5e
1 changed files with 27 additions and 0 deletions
|
@ -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) {
|
func TestConnectionCheck(t *testing.T) {
|
||||||
|
|
||||||
addr, closer := runserver(t, &smtpd.Server{
|
addr, closer := runserver(t, &smtpd.Server{
|
||||||
|
|
Loading…
Add table
Reference in a new issue