mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
smtp: allow empty user & pass during AUTH LOGIN (#225)
This commit is contained in:
@@ -311,21 +311,13 @@ func parseHelloArgument(arg string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) loginHandler(line string) {
|
func (s *Session) loginHandler(line string) {
|
||||||
if len(line) == 0 {
|
// Content and length of username is ignored.
|
||||||
s.send("500 Invalid username")
|
|
||||||
s.enterState(READY)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.send(fmt.Sprintf("334 %v", passwordChallenge))
|
s.send(fmt.Sprintf("334 %v", passwordChallenge))
|
||||||
s.enterState(PASSWORD)
|
s.enterState(PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) passwordHandler(line string) {
|
func (s *Session) passwordHandler(line string) {
|
||||||
if len(line) == 0 {
|
// Content and length of password is ignored.
|
||||||
s.send("500 Invalid password")
|
|
||||||
s.enterState(READY)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.send("235 Authentication successful")
|
s.send("235 Authentication successful")
|
||||||
s.enterState(READY)
|
s.enterState(READY)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,9 +138,13 @@ func TestAuth(t *testing.T) {
|
|||||||
// LOGIN AUTH
|
// LOGIN AUTH
|
||||||
script = []scriptStep{
|
script = []scriptStep{
|
||||||
{"EHLO localhost", 250},
|
{"EHLO localhost", 250},
|
||||||
{"AUTH LOGIN", 334},
|
{"AUTH LOGIN", 334}, // Test with user/pass present.
|
||||||
{"USERNAME", 334},
|
{"username", 334},
|
||||||
{"PASSWORD", 235},
|
{"password", 235},
|
||||||
|
{"RSET", 250},
|
||||||
|
{"AUTH LOGIN", 334}, // Test with empty user/pass.
|
||||||
|
{"", 334},
|
||||||
|
{"", 235},
|
||||||
}
|
}
|
||||||
if err := playSession(t, server, script); err != nil {
|
if err := playSession(t, server, script); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user