From faa9a603a2a73a758866cab3734e8ab41c54b63e Mon Sep 17 00:00:00 2001 From: Alexandre Cesaro Date: Sat, 25 Jul 2015 18:50:36 +0200 Subject: [PATCH] Fixed PLAIN authentication --- auth.go | 2 +- auth_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/auth.go b/auth.go index c7b63d5..4bcdd06 100644 --- a/auth.go +++ b/auth.go @@ -41,7 +41,7 @@ func (a *plainAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { return "LOGIN", nil, nil } - return "PLAIN", []byte(a.username + "\x00" + a.password), nil + return "PLAIN", []byte("\x00" + a.username + "\x00" + a.password), nil } func (a *plainAuth) Next(fromServer []byte, more bool) ([]byte, error) { diff --git a/auth_test.go b/auth_test.go index 092a85f..20b4772 100644 --- a/auth_test.go +++ b/auth_test.go @@ -42,7 +42,7 @@ func TestNoAdvertisementTLS(t *testing.T) { challenges: []string{"Username:", "Password:"}, tls: true, wantProto: "PLAIN", - wantData: []string{testUser + "\x00" + testPwd}, + wantData: []string{"\x00" + testUser + "\x00" + testPwd}, }) } @@ -52,7 +52,7 @@ func TestPlain(t *testing.T) { challenges: []string{"Username:", "Password:"}, tls: false, wantProto: "PLAIN", - wantData: []string{testUser + "\x00" + testPwd}, + wantData: []string{"\x00" + testUser + "\x00" + testPwd}, }) } @@ -62,7 +62,7 @@ func TestPlainTLS(t *testing.T) { challenges: []string{"Username:", "Password:"}, tls: true, wantProto: "PLAIN", - wantData: []string{testUser + "\x00" + testPwd}, + wantData: []string{"\x00" + testUser + "\x00" + testPwd}, }) } @@ -72,7 +72,7 @@ func TestPlainAndLogin(t *testing.T) { challenges: []string{"Username:", "Password:"}, tls: false, wantProto: "PLAIN", - wantData: []string{testUser + "\x00" + testPwd}, + wantData: []string{"\x00" + testUser + "\x00" + testPwd}, }) } @@ -82,7 +82,7 @@ func TestPlainAndLoginTLS(t *testing.T) { challenges: []string{"Username:", "Password:"}, tls: true, wantProto: "PLAIN", - wantData: []string{testUser + "\x00" + testPwd}, + wantData: []string{"\x00" + testUser + "\x00" + testPwd}, }) }