Commit 12ed85a6 authored by Stan Hu's avatar Stan Hu

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

MailRoom supports two inbox modes: IMAP and Microsoft Graph. The former
uses the IMAP protocol, and the latter uses a REST API to retrieve
e-mail.

When we added support for Microsoft Graph, we did not account for this
in the `gitlab:incoming_email:check` Rake task.

For now, disable the IMAP check if is it not configured. We may want to
consider adding a Microsoft Graph-specific check, but MailRoom will exit
if the Microsoft Graph credentials are not configured properly.

Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/214900#note_656345704
parent 3d823895
...@@ -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