`, "DNS re-checked.",
} {
if !strings.Contains(out, want) {
t.Errorf("health page is missing %q", want)
}
}
}
// The certificate card names a renewal Postfix has not taken up yet: its
// expiry and when it was mounted, beside the served one's (A-65).
func TestHealthPageNamesARenewalWaiting(t *testing.T) {
h, _ := settingsServer(t)
c := healthReading()
cert := c["Cert"].(health.Certificate)
cert.Renewal = &health.Renewal{
NotAfter: time.Date(2027, 1, 31, 8, 2, 0, 0, time.UTC),
Mounted: time.Date(2026, 10, 15, 3, 12, 0, 0, time.UTC),
}
cert.Detail = "Postfix still serves the certificate above. A renewed one is waiting in the mounted file."
c["Cert"] = cert
out := renderHealth(t, h, c, "")
for _, want := range []string{
"
Expires", "2026-11-08 09:14 UTC",
"
Renewal expires", "2027-01-31 08:02 UTC",
"
Renewal mounted", "2026-10-15 03:12 UTC",
"Postfix still serves the certificate above.",
} {
if !strings.Contains(out, want) {
t.Errorf("health page is missing %q", want)
}
}
}
// The fragment is what the page holds in its polled rows, read again.
func TestHealthFragmentCarriesTheSameRows(t *testing.T) {
h, _ := settingsServer(t)
h.machine = &health.MachineSampler{}
h.cfg.Hostname = "mail.example.com"
rec := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/server/health/fragment", nil)
h.HandleHealthFragment(rec, auth.RequestWithPrincipal(req, globalPrincipal))
out := rec.Body.String()
if rec.Code != 200 {
t.Fatalf("GET /server/health/fragment = %d:\n%s", rec.Code, out)
}
for _, want := range []string{
`id="health-stack" data-poll`, `hx-get="/server/health/fragment"`,
`id="sockets" hx-swap-oob="true"`, `id="certificate" hx-swap-oob="true"`, `id="notification-mail" hx-swap-oob="true"`,
`id="machine"`, `id="processes"`, `id="sender-check"`, `id="hostname"`,
} {
if !strings.Contains(out, want) {
t.Errorf("health fragment is missing %q", want)
}
}
for _, gone := range []string{"
`, `class="sp-postmark`, `
mail.example.org
`,
`href="/server/health"`, `href="/server/health"`, `href="/outbound/queue"`,
`
Outbound domains
`, `
example.org`,
"DKIM", "SPF", "DMARC", "1\u00a0msg", `
30 days | `,
`href="/server/health"`,
`id="health" data-poll aria-live="polite" hx-get="/overview/fragment" hx-trigger="load" hx-swap="outerHTML"`,
} {
if !strings.Contains(out, want) {
t.Errorf("Overview is missing %q", want)
}
}
// The inbound relay has no service in this test, so its box is not drawn.
for _, gone := range []string{
`action="/server/health/reload"`, `action="/server/health/recheck"`, `id="processes"`, "