test(web): check publicDomain directly

mail.ParseAddress already refuses empty labels such as x..com, so the
form-level tests could not see the empty-label check in publicDomain.
A direct table test pins the rule on its own.
This commit is contained in:
tgiachi 2026-11-10 15:16:02 +01:00
commit 097314e8d9

View file

@ -875,3 +875,16 @@ func TestSubscribeLimiterIsCapped(t *testing.T) {
t.Fatalf("size = %d, want 2", l.size())
}
}
// mail.ParseAddress already refuses most of these; publicDomain must not depend on it.
func TestPublicDomain(t *testing.T) {
for d, want := range map[string]bool{
"example.com": true, "members.test": true, "a-b.example": true, "X1.Example.ORG": true,
"x..com": false, ".x.com": false, "x.com.": false, "x": false, "localhost": false, "[127.0.0.1]": false,
"a.localhost": false, "a.local": false, "a.internal": false, "a.invalid": false, "x_y.com": false,
} {
if got := publicDomain(d); got != want {
t.Errorf("publicDomain(%q) = %v, want %v", d, got, want)
}
}
}