discourse/spec/lib/validators/email_address_validator_spec.rb
Bianca Nenciu d82fcb8af8
Some checks are pending
Licenses / run (push) Waiting to run
Linting / run (push) Waiting to run
Publish Assets / publish-assets (push) Waiting to run
Tests / core backend (push) Waiting to run
Tests / plugins backend (push) Waiting to run
Tests / core frontend (Chrome) (push) Waiting to run
Tests / plugins frontend (push) Waiting to run
Tests / themes frontend (push) Waiting to run
Tests / core system (push) Waiting to run
Tests / plugins system (push) Waiting to run
Tests / themes system (push) Waiting to run
Tests / core frontend (Firefox ESR) (push) Waiting to run
Tests / core frontend (Firefox Evergreen) (push) Waiting to run
Tests / chat system (push) Waiting to run
Tests / merge (push) Blocked by required conditions
FIX: Validate email length (#34786)
* The maximum total length of a user name or other local-part is 64
octets.

* The maximum total length of a domain name or number is 255 octets.
2025-09-11 18:58:07 +03:00

25 lines
758 B
Ruby

# frozen_string_literal: true
RSpec.describe EmailAddressValidator do
it "should match valid emails" do
[
"test@discourse.org",
"good_user@discourse.org",
"incoming+%{reply_key}@discourse.org",
"a" * 64 + "@" + "b" * 251 + ".com",
].each { |email| expect(EmailAddressValidator.valid_value?(email)).to eq(true) }
end
it "should not match invalid emails" do
[
"testdiscourse.org",
"frank@invalid_host.contoso.com",
"frank@invalid_host.com",
"test@discourse.org; a@discourse.org",
"random",
"te=?utf-8?q?st?=@discourse.org",
"",
"test" * 100 + "@" + "test" * 100 + ".com",
].each { |email| expect(EmailAddressValidator.valid_value?(email)).to eq(false) }
end
end