mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
fix test_mail_notification_spec
This commit is contained in:
@@ -145,9 +145,8 @@ RSpec.describe AdminController do
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsafe SMTP adress on the allowlist" do
|
||||
context "with an unsafe SMTP adress on the allowlist", with_ssrf_ip_allowlist: ['127.0.0.1'] do
|
||||
before do
|
||||
allow(OpenProject::Configuration).to receive(:ssrf_protection_ip_allowlist).and_return [IPAddr.new("127.0.0.1")]
|
||||
allow(ActionMailer::Base).to receive(:smtp_settings).and_return({ address: "127.0.0.1" })
|
||||
|
||||
get :test_email
|
||||
|
||||
@@ -38,7 +38,7 @@ RSpec.describe "Test mail notification", :js do
|
||||
visit admin_settings_mail_notifications_path(tab: :notifications)
|
||||
end
|
||||
|
||||
it "shows the correct message on errors in test notification (Regression #28226)" do
|
||||
it "shows the correct message on errors in test notification (Regression #28226)", with_ssrf_ip_allowlist: ['127.0.0.1'] do
|
||||
error_message = '"error" with <strong>Markup?</strong>'
|
||||
expect(UserMailer).to receive(:test_mail).with(admin)
|
||||
.and_raise error_message
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
module WithSsrfIpAllowlistMixin
|
||||
module_function
|
||||
|
||||
def with_ssrf_ip_allowlist(list)
|
||||
addresses = list.map { |str| IPAddr.new str }
|
||||
|
||||
allow(OpenProject::Configuration).to receive(:ssrf_protection_ip_allowlist).and_return addresses
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include WithSsrfIpAllowlistMixin
|
||||
|
||||
config.before :example, :with_ssrf_ip_allowlist do |example|
|
||||
list = example.metadata[:with_ssrf_ip_allowlist]
|
||||
|
||||
with_ssrf_ip_allowlist list
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user