Commit e360a6df authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch 'sh-fix-ms-graph-incoming-email-check' into 'master'

Disable IMAP auth check in Rake task when Microsoft Graph is configured

See merge request gitlab-org/gitlab!68674
parents 83da92d0 12ed85a6
...@@ -251,6 +251,7 @@ Settings.gitlab_ci['url'] ||= Settings.__send__(:build_gitlab_ci ...@@ -251,6 +251,7 @@ Settings.gitlab_ci['url'] ||= Settings.__send__(:build_gitlab_ci
# #
Settings['incoming_email'] ||= Settingslogic.new({}) Settings['incoming_email'] ||= Settingslogic.new({})
Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'].nil? Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'].nil?
Settings.incoming_email['inbox_method'] ||= 'imap'
# #
# Service desk email # Service desk email
......
...@@ -7,9 +7,11 @@ module SystemCheck ...@@ -7,9 +7,11 @@ module SystemCheck
def multi_check def multi_check
if Gitlab.config.incoming_email.enabled if Gitlab.config.incoming_email.enabled
checks = [ checks = []
SystemCheck::IncomingEmail::ImapAuthenticationCheck
] if Gitlab.config.incoming_email.inbox_method == 'imap'
checks << SystemCheck::IncomingEmail::ImapAuthenticationCheck
end
if Rails.env.production? if Rails.env.production?
checks << SystemCheck::IncomingEmail::InitdConfiguredCheck checks << SystemCheck::IncomingEmail::InitdConfiguredCheck
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe SystemCheck::IncomingEmailCheck do
before do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
end
describe '#multi_check' do
context 'when incoming e-mail is disabled' do
before do
stub_incoming_email_setting(enabled: false)
end
it 'does not run any checks' do
expect(SystemCheck).not_to receive(:run)
subject.multi_check
end
end
context 'when incoming e-mail is enabled for IMAP' do
before do
stub_incoming_email_setting(enabled: true)
end
it 'runs IMAP and mailroom checks' do
expect(SystemCheck).to receive(:run).with('Reply by email', [
SystemCheck::IncomingEmail::ImapAuthenticationCheck,
SystemCheck::IncomingEmail::InitdConfiguredCheck,
SystemCheck::IncomingEmail::MailRoomRunningCheck
])
subject.multi_check
end
end
context 'when incoming e-mail is enabled for Microsoft Graph' do
before do
stub_incoming_email_setting(enabled: true, inbox_method: 'microsoft_graph')
end
it 'runs mailroom checks' do
expect(SystemCheck).to receive(:run).with('Reply by email', [
SystemCheck::IncomingEmail::InitdConfiguredCheck,
SystemCheck::IncomingEmail::MailRoomRunningCheck
])
subject.multi_check
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment