Index: openacs-4/packages/acs-templating/tcl/test/data-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/test/Attic/data-procs.tcl,v diff -u -N -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/acs-templating/tcl/test/data-procs.tcl 25 Jun 2021 17:02:03 -0000 1.1.2.1 +++ openacs-4/packages/acs-templating/tcl/test/data-procs.tcl 25 Jun 2021 17:30:14 -0000 1.1.2.2 @@ -30,6 +30,66 @@ } } +aa_register_case -cats { + api + smoke + production_safe +} -procs { + template::data::validate + template::data::validate::email +} validate_email { + Test validation for email + + @author Héctor Romojaro + @creation-date 25 June 2021 +} { + set message "" + # + # Valid emails + # + # See: https://en.wikipedia.org/wiki/Email_address#Examples + # + set valid_mails { + la@lala.la + openacs@openacs.org + whatever.is.this@my.mail.com + discouraged@butvalid + disposable.style.email.with+symbol@example.com + other.email-with-hyphen@example.com + fully-qualified-domain@example.com + user.name+tag+sorting@example.com + x@example.com + example-indeed@strange-example.com + test/test@test.com + example@s.example + john..doe@example.org + mailhost!username@example.org + user%example.com@example.org + user-@example.org + } + foreach mail $valid_mails { + aa_true "Is $mail valid?" [template::data::validate email mail message] + } + # + # Invalid emails + # + set invalid_mails { + @no.valid + no.valid + nope + A@b@c@example.com + {a"b(c)d,e:f;gi[j\k]l@example.com} + {just"not"right@example.com} + {this is"not\allowed@example.com} + {this\ still\"not\\allowed@example.com} + i_like_underscore@but_its_not_allowed_in_this_part.example.com + {QA[icon]CHOCOLATE[icon]@test.com} + } + foreach mail $invalid_mails { + aa_false "Is $mail valid?" [template::data::validate email mail message] + } +} + # Local variables: # mode: tcl # tcl-indent-level: 4