diff options
author | Go MAEDA <maeda@farend.jp> | 2020-04-30 09:00:06 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-04-30 09:00:06 +0000 |
commit | 94c62816a52c13e1cdb91aab6f26c4798897b4a5 (patch) | |
tree | 6df427ce135df8554fc6ded0b95bf2860caaaa2b /test/unit/email_address_test.rb | |
parent | d94226dd4ccc5757a94f3fe1542cdd736831fd48 (diff) | |
download | redmine-94c62816a52c13e1cdb91aab6f26c4798897b4a5.tar.gz redmine-94c62816a52c13e1cdb91aab6f26c4798897b4a5.zip |
Allowed/Disallowed email domains settings to restrict users' email addresses (#3369).
Patch by Yuichi HARADA and Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@19735 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/email_address_test.rb')
-rw-r--r-- | test/unit/email_address_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/unit/email_address_test.rb b/test/unit/email_address_test.rb index 3237d01b4..c3242e25b 100644 --- a/test/unit/email_address_test.rb +++ b/test/unit/email_address_test.rb @@ -30,4 +30,38 @@ class EmailAddressTest < ActiveSupport::TestCase email = EmailAddress.new(address: 'jsmith@example.xn--80akhbyknj4f') assert email.valid? end + + def test_address_should_be_validated_against_denied_domains + with_settings :email_domains_denied => "black.test\r\nBLACK.EXAMPLE, .subdomain.test" do + email = EmailAddress.new(address: 'user@black.test') + assert_not email.valid? + email = EmailAddress.new(address: 'user@notblack.test') + assert email.valid? + email = EmailAddress.new(address: 'user@BLACK.TEST') + assert_not email.valid? + email = EmailAddress.new(address: 'user@black.example') + assert_not email.valid? + email = EmailAddress.new(address: 'user@subdomain.test') + assert email.valid? + email = EmailAddress.new(address: 'user@foo.subdomain.test') + assert_not email.valid? + end + end + + def test_address_should_be_validated_against_allowed_domains + with_settings :email_domains_allowed => "white.test\r\nWHITE.EXAMPLE, .subdomain.test" do + email = EmailAddress.new(address: 'user@white.test') + assert email.valid? + email = EmailAddress.new(address: 'user@notwhite.test') + assert_not email.valid? + email = EmailAddress.new(address: 'user@WHITE.TEST') + assert email.valid? + email = EmailAddress.new(address: 'user@white.example') + assert email.valid? + email = EmailAddress.new(address: 'user@subdomain.test') + assert_not email.valid? + email = EmailAddress.new(address: 'user@foo.subdomain.test') + assert email.valid? + end + end end |