Fixes #3669 - Do not send domain and migrate domain out of Google and Microsoft 365 channels.

This commit is contained in:
Rolf Schmidt 2021-08-10 14:42:56 +02:00 committed by Thorsten Eckel
parent b8aeabce94
commit 884b5c6455
7 changed files with 61 additions and 6 deletions

View file

@ -0,0 +1,12 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
class Issue3669FixDomain < ActiveRecord::Migration[6.0]
def change
return if !Setting.exists?(name: 'system_init_done')
Channel.where(area: ['Google::Account', 'Microsoft365::Account']).each do |channel|
channel.options[:outbound][:options].delete(:domain)
channel.save!
end
end
end

View file

@ -57,7 +57,6 @@ class ExternalCredential::Google
adapter: 'smtp',
options: {
host: 'smtp.gmail.com',
domain: 'gmail.com',
port: 465,
ssl: true,
user: user_data[:email],

View file

@ -61,7 +61,6 @@ class ExternalCredential::Microsoft365
adapter: 'smtp',
options: {
host: 'smtp.office365.com',
domain: 'office365.com',
port: 587,
user: user_data[:preferred_username],
authentication: 'xoauth2',

View file

@ -0,0 +1,49 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe Issue3669FixDomain, type: :db_migration do
let!(:channel) do
channel_options = {
inbound: {
adapter: 'imap',
options: {
auth_type: 'XOAUTH2',
host: 'imap.gmail.com',
ssl: true,
user: 'example@gmail.com',
},
},
outbound: {
adapter: 'smtp',
options: {
host: 'smtp.gmail.com',
domain: 'gmail.com',
port: 465,
ssl: true,
user: 'example@gmail.com',
authentication: 'xoauth2',
},
},
auth: {
provider: 'google',
type: 'XOAUTH2',
client_id: 'abc',
client_secret: 'efg',
},
}
Channel.create!(
area: 'Google::Account',
group_id: Group.first.id,
options: channel_options,
active: false,
created_by_id: 1,
updated_by_id: 1,
)
end
it 'removes domain from the configuration' do
expect { migrate }.to change { channel.reload.options[:outbound][:options][:domain] }.to(nil)
end
end

View file

@ -143,7 +143,6 @@ FactoryBot.define do
'adapter' => 'smtp',
'options' => {
'host' => 'smtp.gmail.com',
'domain' => 'gmail.com',
'port' => 465,
'ssl' => true,
'user' => ENV['GMAIL_USER'],
@ -186,7 +185,6 @@ FactoryBot.define do
'adapter' => 'smtp',
'options' => {
'host' => 'smtp.office365.com',
'domain' => 'office365.com',
'port' => 587,
'user' => ENV['MICROSOFT365_USER'],
'authentication' => 'xoauth2',

View file

@ -129,7 +129,6 @@ RSpec.describe ExternalCredential::Google do
'options' => a_hash_including(
'authentication' => 'xoauth2',
'host' => 'smtp.gmail.com',
'domain' => 'gmail.com',
'port' => 465,
'ssl' => true,
'user' => primary_email,

View file

@ -95,7 +95,6 @@ RSpec.describe ExternalCredential::Microsoft365 do
'options' => a_hash_including(
'authentication' => 'xoauth2',
'host' => 'smtp.office365.com',
'domain' => 'office365.com',
'port' => 587,
'user' => email_address,
)