1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

smtp: fix formatting (#224)

This commit is contained in:
James Hillyerd
2021-07-31 10:32:08 -07:00
committed by GitHub
parent bf8536abb3
commit 4f9f961cac
2 changed files with 17 additions and 13 deletions

View File

@@ -25,6 +25,19 @@ const (
// timeStampFormat to use in Received header. // timeStampFormat to use in Received header.
timeStampFormat = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" timeStampFormat = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)"
// Messages sent to user during LOGIN auth procedure. Can vary, but values are taken directly
// from spec https://tools.ietf.org/html/draft-murchison-sasl-login-00
// usernameChallenge sent when inviting user to provide username. Is base64 encoded string
// `User Name`
usernameChallenge = "VXNlciBOYW1lAA=="
// passwordChallenge sent when inviting user to provide password. Is base64 encoded string
// `Password`
passwordChallenge = "UGFzc3dvcmQA"
)
const (
// GREET State: Waiting for HELO // GREET State: Waiting for HELO
GREET State = iota GREET State = iota
// READY State: Got HELO, waiting for MAIL // READY State: Got HELO, waiting for MAIL
@@ -39,15 +52,6 @@ const (
DATA DATA
// QUIT State: Client requested end of session // QUIT State: Client requested end of session
QUIT QUIT
// Messages sent to user during LOGIN auth procedure
// Can vary, but values are taken directly from spec
// https://tools.ietf.org/html/draft-murchison-sasl-login-00
//usernameChallenge sent when inviting user to provide username. Is base64 encoded string `User Name`
usernameChallenge = "VXNlciBOYW1lAA=="
//passwordChallenge sent when inviting user to provide password. Is base64 encoded string `Password`
passwordChallenge = "UGFzc3dvcmQA"
) )
// fromRegex captures the from address and optional BODY=8BITMIME clause. Matches FROM, while // fromRegex captures the from address and optional BODY=8BITMIME clause. Matches FROM, while
@@ -308,7 +312,7 @@ func parseHelloArgument(arg string) (string, error) {
func (s *Session) loginHandler(line string) { func (s *Session) loginHandler(line string) {
if len(line) == 0 { if len(line) == 0 {
s.send("500 invalid Username") s.send("500 Invalid username")
s.enterState(READY) s.enterState(READY)
return return
} }
@@ -318,7 +322,7 @@ func (s *Session) loginHandler(line string) {
func (s *Session) passwordHandler(line string) { func (s *Session) passwordHandler(line string) {
if len(line) == 0 { if len(line) == 0 {
s.send("500 invalid Password") s.send("500 Invalid password")
s.enterState(READY) s.enterState(READY)
return return
} }

View File

@@ -120,7 +120,7 @@ func TestAuth(t *testing.T) {
server, logbuf, teardown := setupSMTPServer(ds) server, logbuf, teardown := setupSMTPServer(ds)
defer teardown() defer teardown()
//PLAIN AUTH // PLAIN AUTH
script := []scriptStep{ script := []scriptStep{
{"EHLO localhost", 250}, {"EHLO localhost", 250},
{"AUTH PLAIN aW5idWNrZXQ6cGFzc3dvcmQK", 235}, {"AUTH PLAIN aW5idWNrZXQ6cGFzc3dvcmQK", 235},
@@ -135,7 +135,7 @@ func TestAuth(t *testing.T) {
t.Error(err) t.Error(err)
} }
//LOGIN AUTH // LOGIN AUTH
script = []scriptStep{ script = []scriptStep{
{"EHLO localhost", 250}, {"EHLO localhost", 250},
{"AUTH LOGIN", 334}, {"AUTH LOGIN", 334},