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>
89 lines
2.7 KiB
Go
89 lines
2.7 KiB
Go
package domain
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/mixeme/selfpost/internal/store"
|
|
)
|
|
|
|
// countingApps is fakeApps that counts the sender map's rebuilds and can
|
|
// fail them.
|
|
type countingApps struct {
|
|
fakeApps
|
|
resyncs int
|
|
resyncErr error
|
|
}
|
|
|
|
func (c *countingApps) Resync() error {
|
|
c.resyncs++
|
|
return c.resyncErr
|
|
}
|
|
|
|
// A deletion that fails after the domain's row is gone says the domain is
|
|
// deleted, and runs every rebuild anyway: the sender map was left naming the
|
|
// purged logins when OpenDKIM's tables failed first (audit 2026-10-12, L17).
|
|
// The key stays while the tables may still name it.
|
|
func TestDeleteRunsEveryRebuildAndSaysTheDomainIsGone(t *testing.T) {
|
|
apps := &countingApps{}
|
|
s, odk := newTestService(t, apps)
|
|
d, err := s.Add("gone.example")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
keyDir := filepath.Join(odk.keysDir, d.Name)
|
|
apps.resyncs = 0
|
|
|
|
odk.reload = func() error { return errors.New("supervisor away") }
|
|
err = s.Delete(d.ID)
|
|
if !errors.Is(err, ErrDeletedIncomplete) {
|
|
t.Fatalf("Delete with OpenDKIM's reload failing = %v, want ErrDeletedIncomplete", err)
|
|
}
|
|
if _, err := s.Get(d.ID); !errors.Is(err, store.ErrDomainNotFound) {
|
|
t.Errorf("the domain is still in the registry: %v", err)
|
|
}
|
|
if apps.resyncs != 1 {
|
|
t.Errorf("the sender map was rebuilt %d times, want once", apps.resyncs)
|
|
}
|
|
if _, err := os.Stat(keyDir); err != nil {
|
|
t.Errorf("the key went while the tables may still name it: %v", err)
|
|
}
|
|
|
|
// Reload configuration finishes the deletion: the tables rebuilt, the
|
|
// key of a domain that is gone goes too; the others' stay.
|
|
odk.reload = func() error { return nil }
|
|
keep, err := s.Add("kept.example")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := s.Resync(); err != nil {
|
|
t.Fatalf("Resync: %v", err)
|
|
}
|
|
if _, err := os.Stat(keyDir); !os.IsNotExist(err) {
|
|
t.Errorf("the deleted domain's key is still there after Resync: %v", err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(odk.keysDir, keep.Name)); err != nil {
|
|
t.Errorf("Resync removed a domain's key: %v", err)
|
|
}
|
|
}
|
|
|
|
// The sender map failing is the same: deleted, said so; the tables were
|
|
// rebuilt, so the key goes.
|
|
func TestDeleteWithTheSenderMapFailing(t *testing.T) {
|
|
apps := &countingApps{resyncErr: errors.New("postfix away")}
|
|
s, odk := newTestService(t, apps)
|
|
d, err := s.Add("gone.example")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
keyDir := filepath.Join(odk.keysDir, d.Name)
|
|
if err := s.Delete(d.ID); !errors.Is(err, ErrDeletedIncomplete) {
|
|
t.Fatalf("Delete with the sender map failing = %v, want ErrDeletedIncomplete", err)
|
|
}
|
|
if _, err := os.Stat(keyDir); !os.IsNotExist(err) {
|
|
t.Errorf("the key is still there after the tables were rebuilt: %v", err)
|
|
}
|
|
}
|