Add contact antispam and fix gallery video playback.
English-only messages, rate limiting, min fill time, and normalized email validation; improve modal video serving with posters, correct MIME types, and no gzip on gallery media. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,16 +12,33 @@ func TestParse_valid(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParse_normalizesEmail(t *testing.T) {
|
||||
sub, errs := Parse("Jimmy", "Jane Doe <jane@example.com>", "Hello there, this is a test message.")
|
||||
if errs.Any() {
|
||||
t.Fatalf("unexpected errors: %v", errs)
|
||||
}
|
||||
if sub.Email != "jane@example.com" {
|
||||
t.Fatalf("email = %q", sub.Email)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParse_shortMessage(t *testing.T) {
|
||||
_, errs := Parse("Jimmy", "jim@example.com", "short")
|
||||
if !errs.Any() {
|
||||
t.Fatal("expected validation error")
|
||||
if errs["message"] == "" {
|
||||
t.Fatal("expected message error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParse_invalidEmail(t *testing.T) {
|
||||
_, errs := Parse("Jimmy", "not-an-email", "This message is long enough to pass.")
|
||||
_, errs := Parse("Jimmy", "not-an-email", "This message is long enough to pass validation here.")
|
||||
if errs["email"] == "" {
|
||||
t.Fatal("expected email error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParse_notEnglish(t *testing.T) {
|
||||
_, errs := Parse("Jimmy", "jim@example.com", "これは日本語のテストメッセージです。十分な長さがあります。")
|
||||
if errs["message"] == "" {
|
||||
t.Fatal("expected English-only message error")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user