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:
parent
8d28e48360
commit
097314e8d9
1 changed files with 13 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue