Skip to content

Commit

Permalink
Bump go-smtp version, update tests to expect LF in messages
Browse files Browse the repository at this point in the history
Upstream change fixes \r\n\r\n being mangled into \r\n\n.
  • Loading branch information
foxcpp committed Jul 24, 2020
1 parent 18657de commit d95e4f9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/emersion/go-milter v0.1.1-0.20200513090417-c3e74efc8df9
github.com/emersion/go-msgauth v0.5.0
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21
github.com/emersion/go-smtp v0.13.1-0.20200721085548-87b76f44681a
github.com/emersion/go-smtp v0.13.1-0.20200724113925-09421d11e5b0
github.com/foxcpp/go-dovecot-sasl v0.0.0-20200522223722-c4699d7a24bf
github.com/foxcpp/go-imap-i18nlevel v0.0.0-20200208001533-d6ec88553005
github.com/foxcpp/go-imap-sql v0.4.1-0.20200719153150-6551cd572c1c
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/emersion/go-smtp v0.13.1-0.20200521085049-d143b3ef4b5e h1:y2iLWskJUT3
github.com/emersion/go-smtp v0.13.1-0.20200521085049-d143b3ef4b5e/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ=
github.com/emersion/go-smtp v0.13.1-0.20200721085548-87b76f44681a h1:tswS/0NdSOgkDP9I+9lulxsWcLalddcX2t0zSFUB57I=
github.com/emersion/go-smtp v0.13.1-0.20200721085548-87b76f44681a/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ=
github.com/emersion/go-smtp v0.13.1-0.20200724113925-09421d11e5b0 h1:110GWeGuYRg82JJxTAucVmonobbR79ubOWFvDAE5rQM=
github.com/emersion/go-smtp v0.13.1-0.20200724113925-09421d11e5b0/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0zE3qCi6ZrtTf5OUdNm5lDnGnjRSq9GgmeTrg=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/foxcpp/go-dovecot-sasl v0.0.0-20200522223722-c4699d7a24bf h1:rmBPY5fryjp9zLQYsUmQqqgsYq7qeVfrjtr96Tf9vD8=
Expand Down
4 changes: 2 additions & 2 deletions internal/target/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func TestQueueDelivery_AbortNoDangling(t *testing.T) {
IDRaw := sha1.Sum([]byte(t.Name()))
encodedID := hex.EncodeToString(IDRaw[:])

body := buffer.MemoryBuffer{Slice: []byte("foobar")}
body := buffer.MemoryBuffer{Slice: []byte("foobar\r\n")}
ctx := module.MsgMetadata{
DontTraceSender: true,
ID: encodedID,
Expand Down Expand Up @@ -764,7 +764,7 @@ func TestQueueDSN_RcptRewrite(t *testing.T) {
IDRaw := sha1.Sum([]byte(t.Name()))
encodedID := hex.EncodeToString(IDRaw[:])

body := buffer.MemoryBuffer{Slice: []byte("foobar")}
body := buffer.MemoryBuffer{Slice: []byte("foobar\r\n")}
ctx := module.MsgMetadata{
DontTraceSender: true,
OriginalFrom: "test3@example.org",
Expand Down
2 changes: 1 addition & 1 deletion internal/testutils/smtp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (be *SMTPBackend) CheckMsg(t *testing.T, indx int, from string, rcptTo []st
t.Errorf("Wrong RCPT TO: %v", msg.To)
}
if string(msg.Data) != DeliveryData {
t.Errorf("Wrong DATA payload: %v", string(msg.Data))
t.Errorf("Wrong DATA payload: %v (%v)", string(msg.Data), msg.Data)
}
}

Expand Down
14 changes: 7 additions & 7 deletions internal/testutils/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ func DoTestDeliveryNonAtomic(t *testing.T, c module.StatusCollector, tgt module.
return encodedID
}

const DeliveryData = "A: 1\n" +
"B: 2\n" +
"\n" +
"foobar\n"
const DeliveryData = "A: 1\r\n" +
"B: 2\r\n" +
"\r\n" +
"foobar\r\n"

func DoTestDeliveryErr(t *testing.T, tgt module.DeliveryTarget, from string, to []string) (string, error) {
return DoTestDeliveryErrMeta(t, tgt, from, to, &module.MsgMetadata{})
Expand All @@ -241,7 +241,7 @@ func DoTestDeliveryErrMeta(t *testing.T, tgt module.DeliveryTarget, from string,
encodedID := hex.EncodeToString(IDRaw[:])
testCtx := context.Background()

body := buffer.MemoryBuffer{Slice: []byte("foobar\n")}
body := buffer.MemoryBuffer{Slice: []byte("foobar\r\n")}
msgMeta.DontTraceSender = true
msgMeta.ID = encodedID
t.Log("-- tgt.Start", from)
Expand Down Expand Up @@ -318,8 +318,8 @@ func CheckMsgID(t *testing.T, msg *Msg, sender string, rcpt []string, id string)
if !reflect.DeepEqual(msg.RcptTo, rcpt) {
t.Errorf("wrong recipients, want %v, got %v", rcpt, msg.RcptTo)
}
if string(msg.Body) != "foobar\n" {
t.Errorf("wrong body, want '%s', got '%s'", "foobar", string(msg.Body))
if string(msg.Body) != "foobar\r\n" {
t.Errorf("wrong body, want '%s', got '%s' (%v)", "foobar\r\n", string(msg.Body), msg.Body)
}

return msg.MsgMeta.ID
Expand Down

0 comments on commit d95e4f9

Please sign in to comment.