feat(mail-admin): read-only account view for mail.produktor.io (#74)
- admin/: Go stdlib-only HTTP viewer, lists accounts from config/postfix-accounts.cf with per-mailbox message counts (INBOX and total, same numbers doveadm reports) and storage; quota from dovecot-quotas.cf; Basic Auth from .env; offline tests vs fixtures (go test -race ./...) - compose: mail-admin service, build admin/Dockerfile, publishes 127.0.0.1:19945 / 172.17.0.1:19945; config and mail-data mounted :ro, no docker socket - NPM proxy host 66: location /admin/ -> 172.17.0.1:19945 - README: account admin section
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Fixture layout (testdata/mail/produktor.io):
|
||||
//
|
||||
// info/ cur: 2 messages, new: 1 message, .Sent/cur: 1 message
|
||||
// ano/ cur: 1 message
|
||||
// postmaster/ new: 1 message
|
||||
// postman/ cur: (empty)
|
||||
// andriy.oblivantsev/ (missing — like an account with no mail yet)
|
||||
func TestStatMaildirInfo(t *testing.T) {
|
||||
st, err := statMaildir("testdata/mail/produktor.io/info")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.Messages != 3 { // INBOX: cur 2 + new 1
|
||||
t.Errorf("Messages = %d, want 3", st.Messages)
|
||||
}
|
||||
if st.Total != 4 { // INBOX 3 + .Sent 1
|
||||
t.Errorf("Total = %d, want 4", st.Total)
|
||||
}
|
||||
if st.Storage < 1 {
|
||||
t.Errorf("Storage = %d, want > 0", st.Storage)
|
||||
}
|
||||
if st.Newest.IsZero() {
|
||||
t.Error("Newest should be set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatMaildirEmptyMailbox(t *testing.T) {
|
||||
st, err := statMaildir("testdata/mail/produktor.io/postman")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.Messages != 0 || st.Total != 0 || st.Storage != 0 {
|
||||
t.Errorf("postman should be empty, got %+v", st)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatMaildirMissingRoot(t *testing.T) {
|
||||
// An account with no Maildir on disk yet must report zero, not fail.
|
||||
st, err := statMaildir("testdata/mail/produktor.io/andriy.oblivantsev")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.Messages != 0 || st.Total != 0 || st.Storage != 0 {
|
||||
t.Errorf("missing mailbox should be zero, got %+v", st)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user