Fixed PLAIN authentication

This commit is contained in:
Alexandre Cesaro 2015-07-25 18:50:36 +02:00
parent 1d59d94f4e
commit faa9a603a2
2 changed files with 6 additions and 6 deletions

View File

@ -41,7 +41,7 @@ func (a *plainAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
return "LOGIN", nil, nil 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) { func (a *plainAuth) Next(fromServer []byte, more bool) ([]byte, error) {

View File

@ -42,7 +42,7 @@ func TestNoAdvertisementTLS(t *testing.T) {
challenges: []string{"Username:", "Password:"}, challenges: []string{"Username:", "Password:"},
tls: true, tls: true,
wantProto: "PLAIN", 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:"}, challenges: []string{"Username:", "Password:"},
tls: false, tls: false,
wantProto: "PLAIN", 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:"}, challenges: []string{"Username:", "Password:"},
tls: true, tls: true,
wantProto: "PLAIN", 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:"}, challenges: []string{"Username:", "Password:"},
tls: false, tls: false,
wantProto: "PLAIN", 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:"}, challenges: []string{"Username:", "Password:"},
tls: true, tls: true,
wantProto: "PLAIN", wantProto: "PLAIN",
wantData: []string{testUser + "\x00" + testPwd}, wantData: []string{"\x00" + testUser + "\x00" + testPwd},
}) })
} }