mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Fork net/smpt into go-mail
Implemented negative check for AuthLogin Auth method
This commit is contained in:
parent
df7bb9b742
commit
820d1c25d8
1 changed files with 9 additions and 3 deletions
|
@ -34,6 +34,7 @@ type authTest struct {
|
||||||
challenges []string
|
challenges []string
|
||||||
name string
|
name string
|
||||||
responses []string
|
responses []string
|
||||||
|
sf []bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var authTests = []authTest{
|
var authTests = []authTest{
|
||||||
|
@ -42,24 +43,28 @@ var authTests = []authTest{
|
||||||
[]string{},
|
[]string{},
|
||||||
"PLAIN",
|
"PLAIN",
|
||||||
[]string{"\x00user\x00pass"},
|
[]string{"\x00user\x00pass"},
|
||||||
|
[]bool{false, false},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PlainAuth("foo", "bar", "baz", "testserver"),
|
PlainAuth("foo", "bar", "baz", "testserver"),
|
||||||
[]string{},
|
[]string{},
|
||||||
"PLAIN",
|
"PLAIN",
|
||||||
[]string{"foo\x00bar\x00baz"},
|
[]string{"foo\x00bar\x00baz"},
|
||||||
|
[]bool{false, false},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
LoginAuth("user", "pass", "testserver"),
|
LoginAuth("user", "pass", "testserver"),
|
||||||
[]string{"Username:", "Password:"},
|
[]string{"Username:", "Password:", "Invalid:"},
|
||||||
"LOGIN",
|
"LOGIN",
|
||||||
[]string{"", "user", "pass", ""},
|
[]string{"", "user", "pass", ""},
|
||||||
|
[]bool{false, false, true},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CRAMMD5Auth("user", "pass"),
|
CRAMMD5Auth("user", "pass"),
|
||||||
[]string{"<123456.1322876914@testserver>"},
|
[]string{"<123456.1322876914@testserver>"},
|
||||||
"CRAM-MD5",
|
"CRAM-MD5",
|
||||||
[]string{"", "user 287eb355114cf5c471c26a875f1ca4ae"},
|
[]string{"", "user 287eb355114cf5c471c26a875f1ca4ae"},
|
||||||
|
[]bool{false, false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +84,9 @@ testLoop:
|
||||||
for j := range test.challenges {
|
for j := range test.challenges {
|
||||||
challenge := []byte(test.challenges[j])
|
challenge := []byte(test.challenges[j])
|
||||||
expected := []byte(test.responses[j+1])
|
expected := []byte(test.responses[j+1])
|
||||||
|
sf := test.sf[j]
|
||||||
resp, err := test.auth.Next(challenge, true)
|
resp, err := test.auth.Next(challenge, true)
|
||||||
if err != nil {
|
if err != nil && !sf {
|
||||||
t.Errorf("#%d error: %s", i, err)
|
t.Errorf("#%d error: %s", i, err)
|
||||||
continue testLoop
|
continue testLoop
|
||||||
}
|
}
|
||||||
|
@ -157,7 +163,7 @@ func TestAuthLogin(t *testing.T) {
|
||||||
// NOT OK on non-localhost, even if server says PLAIN is OK.
|
// NOT OK on non-localhost, even if server says PLAIN is OK.
|
||||||
// (We don't know that the server is the real server.)
|
// (We don't know that the server is the real server.)
|
||||||
authName: "servername",
|
authName: "servername",
|
||||||
server: &ServerInfo{Name: "servername", Auth: []string{"PLAIN"}},
|
server: &ServerInfo{Name: "servername", Auth: []string{"LOGIN"}},
|
||||||
err: "unencrypted connection",
|
err: "unencrypted connection",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue