test / test (push) Canceled after 0s
- Two inbound domains on one upstream could never change its TLS mode,
each save refused for the other (medium): SetTransportAs changes the
mode for every domain on the upstream when the one saving may change
them all; a domain user who may not is refused with the mode, not the
other tenant's domain name (security F1: the first version named it).
- A deletion's leftover DKIM key is removed by Resync (Reload
configuration, a restore's first start) for names no domain has.
- The backup's write deadline moves before Check.
- hasUnsavedEdit skips password and file fields and compares a multiple
select's options; htmx.config.timeout 30 s, so a refresh never answered
ends and is tried again; a failed refresh's promise is handled.
- An empty filtered Outbound log says no message matches the filters.
- The dummy bcrypt hash is made at start; a DMARC part over 8 MiB is
refused for its size like the other two limits.
- Health's Configuration box says what Reload writes (design first,
32dfe4a).
- Docs: CHANGELOG, guide § Inbound, security.md (the shared upstream's
mode, the profile form's "username taken"), architecture.md (owed to an
address), the plan's notes corrected.
Tests: the shared upstream (service, handler), the leftover key, all eight
Health boxes ordered, the subject from before migration 0011, the new JS
cases.
Tested on the test server: go vet + go test of 25 packages, make e2e (all
pass, 636 s) on this tree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.4 KiB
Go
69 lines
2.4 KiB
Go
package inbound
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/mixeme/selfpost/internal/postfix"
|
|
"github.com/mixeme/selfpost/internal/store"
|
|
)
|
|
|
|
type nullMaps struct{}
|
|
|
|
func (nullMaps) RebuildInboundMaps([]postfix.InboundRoute) error { return nil }
|
|
|
|
// An upstream has one TLS mode, since Postfix keys the policy by the next
|
|
// hop (audit 2026-10-12, L5): the other domains forwarded to it take the mode
|
|
// saved for one of them, when the one saving may change them; one they may
|
|
// not is refused, and nothing is saved. Two domains on one upstream can
|
|
// change its mode (review of stage 4: they could not, each refused for the
|
|
// other).
|
|
func TestOneTLSModePerUpstream(t *testing.T) {
|
|
st, err := store.Open(t.TempDir() + "/test.db")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer st.Close()
|
|
s := NewService(st, nullMaps{})
|
|
a, _ := s.Add("a.example")
|
|
b, _ := s.Add("b.example")
|
|
c, _ := s.Add("c.example")
|
|
mode := func(id int64) string {
|
|
d, err := st.GetInboundDomain(id)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return d.TLSMode
|
|
}
|
|
all := func(store.InboundDomain) bool { return true }
|
|
|
|
if _, err := s.SetTransportAs(a.ID, "10.0.0.8", "25", "encrypt", all); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if n, err := s.SetTransportAs(b.ID, "[10.0.0.8]", "25", "encrypt", all); err != nil || n != 0 {
|
|
t.Fatalf("the same mode: %d, %v", n, err)
|
|
}
|
|
// Either domain changes the mode, for both.
|
|
if n, err := s.SetTransportAs(a.ID, "10.0.0.8", "25", "may", all); err != nil || n != 1 {
|
|
t.Fatalf("a changes the shared mode: %d, %v", n, err)
|
|
}
|
|
if mode(a.ID) != "may" || mode(b.ID) != "may" {
|
|
t.Errorf("modes after a's change: %s, %s", mode(a.ID), mode(b.ID))
|
|
}
|
|
// Another port is another next hop.
|
|
if n, err := s.SetTransportAs(c.ID, "10.0.0.8", "2525", "none", all); err != nil || n != 0 {
|
|
t.Errorf("another port: %d, %v", n, err)
|
|
}
|
|
|
|
// One that may not change b is refused, with b's mode, and saves nothing.
|
|
notB := func(d store.InboundDomain) bool { return d.ID != b.ID }
|
|
_, err = s.SetTransportAs(c.ID, "10.0.0.8", "25", "encrypt", notB)
|
|
var shared *UpstreamShared
|
|
if !errors.As(err, &shared) || shared.Mode != "may" || shared.Domain != "b.example" || shared.Upstream != "[10.0.0.8]:25" {
|
|
t.Fatalf("a mode for another's upstream = %v", err)
|
|
}
|
|
if d, _ := st.GetInboundDomain(c.ID); d.Port != 2525 || mode(a.ID) != "may" {
|
|
t.Errorf("the refused save changed something: c on %d, a %s", d.Port, mode(a.ID))
|
|
}
|
|
}
|