- Rename the Go module from codeberg.org/squidd/parsimony to git.kmalloc.org/squid/parsimony in go.mod and every import. - Fix .gitignore: the bare `parsimony` pattern also ignored the cmd/parsimony folder, so the main package was never committed and a clean checkout could not be built. Anchor it to the root (`/parsimony`) and add cmd/parsimony.
32 lines
1 KiB
Go
32 lines
1 KiB
Go
package ingest
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/emersion/go-smtp"
|
|
|
|
"git.kmalloc.org/squid/parsimony/internal/store"
|
|
)
|
|
|
|
func TestANonPublisherIsRefusedPermanentlyByANewsletter(t *testing.T) {
|
|
st := newStack(t, nil)
|
|
l, _ := st.store.FindList("dev@example.org")
|
|
st.store.SetPolicies(l.ID, store.PostPublishers, store.JoinOpen, store.ArchivePrivate)
|
|
res := deliver(t, st.addr, "alice@example.com", []string{"dev@example.org"})
|
|
var se *smtp.SMTPError
|
|
if !errors.As(res["dev@example.org"], &se) || se.Code != 550 ||
|
|
se.EnhancedCode != (smtp.EnhancedCode{5, 7, 1}) || !strings.HasSuffix(se.Message, "only the publishers of this list may post") {
|
|
t.Fatalf("want 550 5.7.1, got %v", res["dev@example.org"])
|
|
}
|
|
if st.queued(t) != 0 {
|
|
t.Fatal("nothing may be queued")
|
|
}
|
|
|
|
st.store.SetPublisher(l.ID, "alice@example.com", true)
|
|
if res := deliver(t, st.addr, "alice@example.com", []string{"dev@example.org"}); res["dev@example.org"] != nil {
|
|
t.Fatalf("a publisher posts: %v", res["dev@example.org"])
|
|
}
|
|
st.sent(t, 2)
|
|
}
|