Fixes #3669 - Do not send domain and migrate domain out of Google and Microsoft 365 channels.
This commit is contained in:
parent
b8aeabce94
commit
884b5c6455
7 changed files with 61 additions and 6 deletions
12
db/migrate/20210810091200_issue_3669_fix_domain.rb
Normal file
12
db/migrate/20210810091200_issue_3669_fix_domain.rb
Normal 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
|
|
@ -57,7 +57,6 @@ class ExternalCredential::Google
|
||||||
adapter: 'smtp',
|
adapter: 'smtp',
|
||||||
options: {
|
options: {
|
||||||
host: 'smtp.gmail.com',
|
host: 'smtp.gmail.com',
|
||||||
domain: 'gmail.com',
|
|
||||||
port: 465,
|
port: 465,
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: user_data[:email],
|
user: user_data[:email],
|
||||||
|
|
|
@ -61,7 +61,6 @@ class ExternalCredential::Microsoft365
|
||||||
adapter: 'smtp',
|
adapter: 'smtp',
|
||||||
options: {
|
options: {
|
||||||
host: 'smtp.office365.com',
|
host: 'smtp.office365.com',
|
||||||
domain: 'office365.com',
|
|
||||||
port: 587,
|
port: 587,
|
||||||
user: user_data[:preferred_username],
|
user: user_data[:preferred_username],
|
||||||
authentication: 'xoauth2',
|
authentication: 'xoauth2',
|
||||||
|
|
49
spec/db/migrate/issue_3669_fix_domain_spec.rb
Normal file
49
spec/db/migrate/issue_3669_fix_domain_spec.rb
Normal 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
|
|
@ -143,7 +143,6 @@ FactoryBot.define do
|
||||||
'adapter' => 'smtp',
|
'adapter' => 'smtp',
|
||||||
'options' => {
|
'options' => {
|
||||||
'host' => 'smtp.gmail.com',
|
'host' => 'smtp.gmail.com',
|
||||||
'domain' => 'gmail.com',
|
|
||||||
'port' => 465,
|
'port' => 465,
|
||||||
'ssl' => true,
|
'ssl' => true,
|
||||||
'user' => ENV['GMAIL_USER'],
|
'user' => ENV['GMAIL_USER'],
|
||||||
|
@ -186,7 +185,6 @@ FactoryBot.define do
|
||||||
'adapter' => 'smtp',
|
'adapter' => 'smtp',
|
||||||
'options' => {
|
'options' => {
|
||||||
'host' => 'smtp.office365.com',
|
'host' => 'smtp.office365.com',
|
||||||
'domain' => 'office365.com',
|
|
||||||
'port' => 587,
|
'port' => 587,
|
||||||
'user' => ENV['MICROSOFT365_USER'],
|
'user' => ENV['MICROSOFT365_USER'],
|
||||||
'authentication' => 'xoauth2',
|
'authentication' => 'xoauth2',
|
||||||
|
|
|
@ -129,7 +129,6 @@ RSpec.describe ExternalCredential::Google do
|
||||||
'options' => a_hash_including(
|
'options' => a_hash_including(
|
||||||
'authentication' => 'xoauth2',
|
'authentication' => 'xoauth2',
|
||||||
'host' => 'smtp.gmail.com',
|
'host' => 'smtp.gmail.com',
|
||||||
'domain' => 'gmail.com',
|
|
||||||
'port' => 465,
|
'port' => 465,
|
||||||
'ssl' => true,
|
'ssl' => true,
|
||||||
'user' => primary_email,
|
'user' => primary_email,
|
||||||
|
|
|
@ -95,7 +95,6 @@ RSpec.describe ExternalCredential::Microsoft365 do
|
||||||
'options' => a_hash_including(
|
'options' => a_hash_including(
|
||||||
'authentication' => 'xoauth2',
|
'authentication' => 'xoauth2',
|
||||||
'host' => 'smtp.office365.com',
|
'host' => 'smtp.office365.com',
|
||||||
'domain' => 'office365.com',
|
|
||||||
'port' => 587,
|
'port' => 587,
|
||||||
'user' => email_address,
|
'user' => email_address,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue