"runtime"
"strings"
"testing"
+
+ "github.com/uber-go/zap"
)
func _fl(depth int) string {
if err != nil {
return
}
- go AcceptConnection(conn, po)
+ go AcceptConnection(conn, po, zap.New(zap.NullEncoder()))
}
}()
return l
var err error
conn.mailFrom, err = mail.ParseAddress(mailFrom)
- if err != nil {
+ if err != nil || conn.mailFrom == nil {
conn.reply(ReplyBadSyntax)
return
}
address, err := mail.ParseAddress(rcptTo)
if err != nil {
conn.reply(ReplyBadSyntax)
+ return
}
if reply := conn.server.VerifyAddress(*address); reply != ReplyOK {
"strings"
"testing"
"time"
+
+ "github.com/uber-go/zap"
)
func _fl(depth int) string {
if err != nil {
return
}
- go AcceptConnection(conn, server)
+ go AcceptConnection(conn, server, zap.New(zap.NullEncoder()))
}
}()
})
}
+func TestBadAddress(t *testing.T) {
+ l := runServer(t, &testServer{})
+ defer l.Close()
+
+ conn := createClient(t, l.Addr())
+ readCodeLine(t, conn, 220)
+
+ runTableTest(t, conn, []requestResponse{
+ {"EHLO test", 0, func(t testing.TB, conn *textproto.Conn) { conn.ReadResponse(250) }},
+ {"MAIL FROM:<sender>", 501, nil},
+ {"MAIL FROM:<sender@foo.com>", 250, nil},
+ {"RCPT TO:<banned.net>", 501, nil},
+ {"QUIT", 221, nil},
+ })
+}
+
func TestCaseSensitivty(t *testing.T) {
s := &testServer{}
l := runServer(t, s)
conn.ehlo = test.params.ehlo
conn.esmtp = test.params.esmtp
- conn.tls = test.params.tls
+ //conn.tls = test.params.tls
envelope := Envelope{
RcptTo: []mail.Address{{"", test.params.address}},