Decided by the owner on 2026-10-13 (out of preflight); the sender is his
choice of 2026-10-16 ("Да, адрес годится"); mockups e92769f, e3b2501,
8f0ccf9, the route guard 75f97c9.
Card 09 on Health, in the right stack's static end (the left stack is
polled whole): one recipient and Send. HandleTestMessage (global role)
takes one address (validate.AccountEmail - no list, nothing that reads as
an option), at most ten an hour counted from the send log, writes the
message's send-log row first (store.InsertTestMessage: queued, the
hostname as domain, no application, no queue id), awaits its Message-ID
(logtail.AwaitMessageID) and hands it to sendmail as notifications go
(notify.Mailer.SendWithID: postmaster@ the hostname, signed by the local
socket with the key of the server's own name). The browser lands on the
row; the tailer gives it its queue id from cleanup's message-id= line
(src/cleanup/cleanup_message.c:639) and from then on its delivery lines
its status. Postfix refusing the hand-over removes the row; sendmail out
of time keeps it (postdrop may have queued it). The sweep closes a row
whose id was never seen once it is no longer awaited
(CloseUnmatchedTestMessages); an id awaited past ten minutes is not taken.
Reviewed for security before the commit (2026-10-17): no high or medium;
its three low findings are fixed in this commit (the unmatched row's
close, the awaited id's age, the timeout keeping the row) and the
security.md bullet says how the queue id is matched.
Tests: TestTestMessage (refusals, the row and the page, Postfix refusing,
the hourly ten), TestTestMessageTimeoutKeepsTheRow, TestTestMessageRows,
TestCloseUnmatchedTestMessages, TestAwaitedMessageID,
TestRunGivesTheTestMessageItsQueueID, TestHealthTestMessageCard; e2e sends
one to the sink: the row is sent with a long queue id, the sink has it
signed d=mail.e2e.test. go vet + go test (26 packages) and make e2e on the
test server for this tree.
Docs: help (word for word with the mockup), guide § Overview and Health,
architecture § Log tailer, security.md, CHANGELOG [Unreleased] § Added,
roadmap row done.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
package e2e
|
||
|
||
import (
|
||
"net/url"
|
||
"regexp"
|
||
"strings"
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
// testTestMessage: the test message of Server › Health (test-email) goes to
|
||
// the sink from postmaster@ the stand's hostname. The browser lands on its
|
||
// row in the Outbound log, which learns its queue id from cleanup's
|
||
// Message-ID line and then its status from the delivery line, as any row;
|
||
// the sink has it, signed with the key of the stand's own name.
|
||
func testTestMessage(t *testing.T, sc *scenario) {
|
||
before := sinkMessagesWith(t, h.stageDir, "Subject: SelfPost test message")
|
||
resp, body, err := sc.panel.postForm("/server/health/test-message", url.Values{"recipient": {recipient}})
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
m := regexp.MustCompile(`^/outbound/log/(\d+)$`).FindStringSubmatch(resp.Request.URL.Path)
|
||
if resp.StatusCode != 200 || m == nil {
|
||
t.Fatalf("send a test message: status %d, landed on %s:\n%.800s", resp.StatusCode, resp.Request.URL.Path, body)
|
||
}
|
||
page := resp.Request.URL.Path
|
||
if err := waitFor("the test message to be sent", 60*time.Second, time.Second, func() (bool, error) {
|
||
_, body, err := sc.panel.get(page)
|
||
if err != nil {
|
||
return false, err
|
||
}
|
||
qid := regexp.MustCompile(`<dt>Queue id</dt><dd class="sp-mono">([^<]+)</dd>`).FindStringSubmatch(body)
|
||
if strings.Contains(body, `<span class="tag is-success is-light">sent</span>`) && qid != nil && longQueueID.MatchString(qid[1]) {
|
||
return true, nil
|
||
}
|
||
return false, nil
|
||
}); err != nil {
|
||
_, body, _ := sc.panel.get(page)
|
||
t.Fatalf("%v\n%.3000s\n%s", err, body, mailLogTail(h, "postfix/"))
|
||
}
|
||
if err := waitFor("the sink to have it", 30*time.Second, time.Second, func() (bool, error) {
|
||
return sinkMessagesWith(t, h.stageDir, "Subject: SelfPost test message") > before, nil
|
||
}); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
raw, err := findSinkMessage(h.stageDir, "Subject: SelfPost test message", time.Second)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if !strings.Contains(string(raw), "d="+selfpostHostname) || !strings.Contains(string(raw), "From: SelfPost <postmaster@"+selfpostHostname+">") {
|
||
t.Fatalf("the test message at the sink is not the server's own, signed with its name:\n%.2000s", raw)
|
||
}
|
||
}
|