Stage 2, step 5. Written by Sonnet, reviewed by Opus.
- Three pages named after their mockups: in-domains, in-domain,
in-domain-delete, with typed page data (view/inbound.go), fixtures
and tests. The engine pages inbound, inbound_domain and
inbound_delete are gone with their templates and are off
legacy_pages.txt.
- The Spam filter box (plan, Who sees what). The panel now reads
INBOUND_ANTISPAM_MILTER and INBOUND_ANTISPAM_MILTER_ACTION, with the
semantics of build/postfix-config.sh (on only with the inbound relay
on and a milter set; accept | tempfail). It reports them, nothing
more:
on Applies to / Filter (the address, global role only) / If the
filter is down (accepted unfiltered | deferred)
off one sentence; the variable is named for the global role only
The list shows "Spam filter on|off" in its head.
- Handlers pass typed data; routes, POST targets, field names,
validation and authorization (global: all inbound domains; domain
role: the assigned ones, another tenant's id is a 404; add and
delete are global-only) are unchanged. A test saves the upstream and
recipients forms untouched and finds the domain unchanged.
Left out of the mockups' Spam filter box and menu - no source before
inbound-antispam-panel (2.1): the engine name, the quarantine row, the
"refused at the door, see the log" row, the lists row, "Log for this
domain". Also "Checked N min ago" on the MX box: the check carries no
time.
Not done: the filter's socket on Health and Overview. internal/health
checks a unix socket by stat; the documented form of the filter's
address is inet:host:port and needs a dial that does not exist yet.
Differences from the mockups, for the owner:
- refusals and confirmations are the kit flash above the boxes;
- the MX tag is coloured by the check in every state; an MX that
points elsewhere shows "In DNS now";
- the lead of the domain page follows what is saved ("Not accepting
mail yet: no upstream is saved");
- the delete page lists only what the domain has;
- /help#inbound opens Help at the top until the Help step.
Evidence
- docs/assets/panel-redesign/evidence/in-domains.png, in-domain.png,
in-domain-delete.png: 1440 px wide, headless Edge, real templates
served locally with their fixtures (filter on) - NOT from the
container (no Docker on this machine).
- panel/audit.js on the three pages at 1440 and 1280: 352 texts
checked, problems: [].
- That the panel process sees the two variables inside the container
is read from supervisord.conf and entrypoint.sh, not run.
- go test -count=1 ./internal/web/... ./cmd/panel
ok internal/web
ok internal/web/auth
ok internal/web/handlers
ok internal/web/validate
ok internal/web/view
ok cmd/panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
173 lines
4.5 KiB
Go
173 lines
4.5 KiB
Go
package main
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// documentedPublic matches docs/guide.md "Environment variables" table.
|
|
var documentedPublic = []string{
|
|
"SELFPOST_HOSTNAME",
|
|
"SUBMISSION_ENABLE",
|
|
"RATE_LIMIT_MESSAGES_PER_IP",
|
|
"RATE_LIMIT_WINDOW_SECONDS",
|
|
"SEND_LOG_RETENTION_DAYS",
|
|
"PANEL_SESSION_IDLE_DAYS",
|
|
"SELFPOST_DNS_RESOLVERS",
|
|
"TRUSTED_PROXY_CIDR",
|
|
"INBOUND_RELAY_ENABLE",
|
|
"INBOUND_ANTISPAM_MILTER",
|
|
"INBOUND_ANTISPAM_MILTER_ACTION",
|
|
"INBOUND_RATE_LIMIT_MESSAGES_PER_IP",
|
|
"INBOUND_MESSAGE_SIZE_LIMIT",
|
|
"DMARC_REPORTS_ENABLE",
|
|
"DMARC_RATE_LIMIT_MESSAGES_PER_IP",
|
|
"DMARC_MESSAGE_SIZE_LIMIT",
|
|
}
|
|
|
|
// documentedInternal matches architecture.md § Configuration "Internal env vars".
|
|
var documentedInternal = []string{
|
|
"SELFPOST_DATA_DIR",
|
|
"SELFPOST_DB_PATH",
|
|
"SELFPOST_SETUP_TOKEN_FILE",
|
|
"PANEL_HTTP_ADDR",
|
|
"JOURNAL_MILTER_SOCKET",
|
|
"MAIL_LOG",
|
|
"PANEL_COOKIE_SECURE",
|
|
"OPENDKIM_SOCKET",
|
|
"OPENDKIM_DIR",
|
|
"DKIM_SELECTOR_DEFAULT",
|
|
"SASL_DB_PATH",
|
|
"SASL_REALM",
|
|
"POSTFIX_DIR",
|
|
"POSTFIX_SENDER_LOGIN_MAPS",
|
|
"POSTFIX_QUEUE_DIR",
|
|
"POSTFIX_RELAY_DOMAINS",
|
|
"POSTFIX_TRANSPORT_MAPS",
|
|
"POSTFIX_RELAY_RECIPIENTS",
|
|
"POSTFIX_TLS_POLICY_MAPS",
|
|
"POSTFIX_DMARC_RECIPIENTS",
|
|
"POSTFIX_DMARC_TRANSPORT",
|
|
"POSTFIX_DMARC_RELAY_DOMAINS",
|
|
"SELFPOST_DEPLOY_ROOT",
|
|
"MILTER_CONNECT_TIMEOUT",
|
|
"MILTER_COMMAND_TIMEOUT",
|
|
"MILTER_CONTENT_TIMEOUT",
|
|
"MILTER_WAIT_TIMEOUT",
|
|
"TLS_RELOAD_INTERVAL_SECONDS",
|
|
"LOGROTATE_INTERVAL_SECONDS",
|
|
}
|
|
|
|
// documentedComposeFixed are env keys documented outside the table (TLS paths fixed in compose).
|
|
var documentedComposeFixed = []string{
|
|
"TLS_CERT_FILE",
|
|
"TLS_KEY_FILE",
|
|
}
|
|
|
|
// loadConfigKeys is every environment variable read by loadConfig() in main.go.
|
|
// Update together with loadConfig when adding a new key.
|
|
var loadConfigKeys = []string{
|
|
"SELFPOST_DATA_DIR",
|
|
"PANEL_HTTP_ADDR",
|
|
"JOURNAL_MILTER_SOCKET",
|
|
"MAIL_LOG",
|
|
"SEND_LOG_RETENTION_DAYS",
|
|
"SELFPOST_DB_PATH",
|
|
"SELFPOST_SETUP_TOKEN_FILE",
|
|
"SELFPOST_HOSTNAME",
|
|
"PANEL_COOKIE_SECURE",
|
|
"SUBMISSION_ENABLE",
|
|
"TRUSTED_PROXY_CIDR",
|
|
"PANEL_SESSION_IDLE_DAYS",
|
|
"SELFPOST_DNS_RESOLVERS",
|
|
"TLS_CERT_FILE",
|
|
"OPENDKIM_SOCKET",
|
|
"OPENDKIM_DIR",
|
|
"DKIM_SELECTOR_DEFAULT",
|
|
"SASL_DB_PATH",
|
|
"SASL_REALM",
|
|
"POSTFIX_DIR",
|
|
"SELFPOST_DEPLOY_ROOT",
|
|
"INBOUND_RELAY_ENABLE",
|
|
"INBOUND_ANTISPAM_MILTER",
|
|
"INBOUND_ANTISPAM_MILTER_ACTION",
|
|
"DMARC_REPORTS_ENABLE",
|
|
}
|
|
|
|
// buildScriptKeys is every ${VAR:-…} / os.Getenv used in build/*.sh and entrypoint.sh
|
|
// but not necessarily in loadConfig. Update when startup scripts gain a new knob.
|
|
var buildScriptKeys = []string{
|
|
"SELFPOST_HOSTNAME",
|
|
"TLS_CERT_FILE",
|
|
"TLS_KEY_FILE",
|
|
"RATE_LIMIT_MESSAGES_PER_IP",
|
|
"RATE_LIMIT_WINDOW_SECONDS",
|
|
"OPENDKIM_SOCKET",
|
|
"JOURNAL_MILTER_SOCKET",
|
|
"MAIL_LOG",
|
|
"POSTFIX_SENDER_LOGIN_MAPS",
|
|
"POSTFIX_QUEUE_DIR",
|
|
"SASL_DB_PATH",
|
|
"SUBMISSION_ENABLE",
|
|
"INBOUND_RELAY_ENABLE",
|
|
"INBOUND_ANTISPAM_MILTER",
|
|
"INBOUND_ANTISPAM_MILTER_ACTION",
|
|
"INBOUND_RATE_LIMIT_MESSAGES_PER_IP",
|
|
"INBOUND_MESSAGE_SIZE_LIMIT",
|
|
"DMARC_REPORTS_ENABLE",
|
|
"DMARC_RATE_LIMIT_MESSAGES_PER_IP",
|
|
"DMARC_MESSAGE_SIZE_LIMIT",
|
|
"POSTFIX_RELAY_DOMAINS",
|
|
"POSTFIX_TRANSPORT_MAPS",
|
|
"POSTFIX_RELAY_RECIPIENTS",
|
|
"POSTFIX_TLS_POLICY_MAPS",
|
|
"POSTFIX_DMARC_RECIPIENTS",
|
|
"POSTFIX_DMARC_TRANSPORT",
|
|
"POSTFIX_DMARC_RELAY_DOMAINS",
|
|
"MILTER_CONNECT_TIMEOUT",
|
|
"MILTER_COMMAND_TIMEOUT",
|
|
"MILTER_CONTENT_TIMEOUT",
|
|
"MILTER_WAIT_TIMEOUT",
|
|
"TLS_RELOAD_INTERVAL_SECONDS",
|
|
"LOGROTATE_INTERVAL_SECONDS",
|
|
}
|
|
|
|
func documentedKeys() []string {
|
|
keys := append([]string{}, documentedPublic...)
|
|
keys = append(keys, documentedInternal...)
|
|
keys = append(keys, documentedComposeFixed...)
|
|
slices.Sort(keys)
|
|
return slices.Compact(keys)
|
|
}
|
|
|
|
func TestLoadConfigKeysDocumented(t *testing.T) {
|
|
doc := documentedKeys()
|
|
for _, key := range loadConfigKeys {
|
|
if !slices.Contains(doc, key) {
|
|
t.Errorf("loadConfig reads %s but it is not listed in guide.md public, internal, or compose-fixed env docs", key)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBuildScriptKeysDocumented(t *testing.T) {
|
|
doc := documentedKeys()
|
|
for _, key := range buildScriptKeys {
|
|
if !slices.Contains(doc, key) {
|
|
t.Errorf("build scripts read %s but it is not listed in guide.md env documentation", key)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDocumentedKeysAreRead(t *testing.T) {
|
|
read := append([]string{}, loadConfigKeys...)
|
|
read = append(read, buildScriptKeys...)
|
|
slices.Sort(read)
|
|
read = slices.Compact(read)
|
|
|
|
for _, key := range documentedKeys() {
|
|
if !slices.Contains(read, key) {
|
|
t.Errorf("guide.md documents %s but no code in loadConfig or build scripts reads it", key)
|
|
}
|
|
}
|
|
}
|