Commit 4ea6ad65 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'sh-update-mailroom-config' into 'master'

Add support for configuring Microsoft Graph support with MailRoom

See merge request gitlab-org/gitlab!58250
parents d7dc9398 8b1e51ac
---
title: Add config support for using Microsoft Graph with MailRoom
merge_request: 58250
author:
type: added
......@@ -210,6 +210,13 @@ production: &base
# Whether to expunge (permanently remove) messages from the mailbox when they are deleted after delivery
expunge_deleted: false
# For Microsoft Graph support
# inbox_method: microsoft_graph
# inbox_options:
# tenant_id: "YOUR-TENANT-ID"
# client_id: "YOUR-CLIENT-ID"
# client_secret: "YOUR-CLIENT-SECRET"
## Consolidated object store config
## This will only take effect if the object_store sections are not defined
## within the types (e.g. artifacts, lfs, etc.).
......
......@@ -19,6 +19,13 @@
:delete_after_delivery: true
:expunge_deleted: <%= config[:expunge_deleted].to_json %>
<% if config[:inbox_method] %>
:inbox_method: <%= config[:inbox_method] %>
<% end %>
<% if config[:inbox_options].is_a?(Hash) %>
<%= config.slice(:inbox_options).to_yaml(indentation: 8).gsub(/^---\n/, '') %>
<% end %>
:delivery_method: sidekiq
:delivery_options:
:redis_url: <%= config[:redis_url].to_json %>
......
......@@ -16,7 +16,9 @@ RSpec.describe 'mail_room.yml' do
}
cmd = "puts ERB.new(File.read(#{absolute_path(mailroom_config_path).inspect})).result"
output, status = Gitlab::Popen.popen(%W(ruby -rerb -e #{cmd}), absolute_path('config'), vars)
result = Gitlab::Popen.popen_with_detail(%W(ruby -rerb -e #{cmd}), absolute_path('config'), vars)
output = result.stdout
status = result.status
raise "Error interpreting #{mailroom_config_path}: #{output}" unless status == 0
YAML.load(output)
......@@ -68,6 +70,39 @@ RSpec.describe 'mail_room.yml' do
end
end
context 'when both incoming email and service desk email are enabled for Microsoft Graph' do
let(:gitlab_config_path) { 'spec/fixtures/config/mail_room_enabled_ms_graph.yml' }
let(:queues_config_path) { 'spec/fixtures/config/redis_queues_new_format_host.yml' }
let(:gitlab_redis_queues) { Gitlab::Redis::Queues.new(Rails.env) }
it 'contains the intended configuration' do
expected_mailbox = {
email: 'gitlab-incoming@gmail.com',
name: 'inbox',
idle_timeout: 60,
expunge_deleted: true
}
expected_options = {
redis_url: gitlab_redis_queues.url,
sentinels: gitlab_redis_queues.sentinels
}
expected_inbox_options = {
tenant_id: '12345',
client_id: 'MY-CLIENT-ID',
client_secret: 'MY-CLIENT-SECRET',
poll_interval: 60
}
expect(configuration[:mailboxes].length).to eq(2)
expect(configuration[:mailboxes]).to all(include(expected_mailbox))
expect(configuration[:mailboxes].map { |m| m[:inbox_method] }).to all(eq('microsoft_graph'))
expect(configuration[:mailboxes].map { |m| m[:inbox_options] }).to all(eq(expected_inbox_options))
expect(configuration[:mailboxes].map { |m| m[:delivery_options] }).to all(include(expected_options))
expect(configuration[:mailboxes].map { |m| m[:delivery_options] }).to all(include(expected_options))
expect(configuration[:mailboxes].map { |m| m[:arbitration_options] }).to all(include(expected_options))
end
end
def clear_queues_raw_config
Gitlab::Redis::Queues.remove_instance_variable(:@_raw_config)
rescue NameError
......
test:
incoming_email:
enabled: true
address: "gitlab-incoming+%{key}@gmail.com"
user: "gitlab-incoming@gmail.com"
mailbox: "inbox"
expunge_deleted: true
inbox_method: "microsoft_graph"
inbox_options:
tenant_id: "12345"
client_id: "MY-CLIENT-ID"
client_secret: "MY-CLIENT-SECRET"
poll_interval: 60
service_desk_email:
enabled: true
address: "gitlab-incoming+%{key}@gmail.com"
user: "gitlab-incoming@gmail.com"
mailbox: "inbox"
expunge_deleted: true
inbox_method: "microsoft_graph"
inbox_options:
tenant_id: "12345"
client_id: "MY-CLIENT-ID"
client_secret: "MY-CLIENT-SECRET"
poll_interval: 60
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