From 94c62816a52c13e1cdb91aab6f26c4798897b4a5 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 30 Apr 2020 09:00:06 +0000 Subject: 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 --- test/functional/email_addresses_controller_test.rb | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/functional/email_addresses_controller_test.rb') diff --git a/test/functional/email_addresses_controller_test.rb b/test/functional/email_addresses_controller_test.rb index 76ff0a561..deb996105 100644 --- a/test/functional/email_addresses_controller_test.rb +++ b/test/functional/email_addresses_controller_test.rb @@ -118,6 +118,36 @@ class EmailAddressesControllerTest < Redmine::ControllerTest end end + def test_create_with_disallowed_domain_should_fail + @request.session[:user_id] = 2 + + with_settings :email_domains_denied => 'black.example' do + assert_no_difference 'EmailAddress.count' do + post :create, :params => { + :user_id => 2, + :email_address => { + :address => 'another@black.example' + } + } + assert_response :success + assert_select_error 'Email is invalid' + end + end + + with_settings :email_domains_allowed => 'white.example' do + assert_no_difference 'EmailAddress.count' do + post :create, :params => { + :user_id => 2, + :email_address => { + :address => 'something@example.fr' + } + } + assert_response :success + assert_select_error 'Email is invalid' + end + end + end + def test_create_should_send_security_notification @request.session[:user_id] = 2 ActionMailer::Base.deliveries.clear -- cgit v1.2.3