From 1723d57cdd7acefa1907d9a23ecdd8eccfa42d86 Mon Sep 17 00:00:00 2001 From: Dominik Klein Date: Mon, 26 Jul 2021 10:43:50 +0200 Subject: [PATCH] Fixes #3627 - Outdated urls on security page (third-party logins). --- ...170713000001_omniauth_office365_setting.rb | 2 +- ..._issue_3627_outdated_urls_security_page.rb | 15 +++++++++ db/seeds/settings.rb | 4 +-- ...e_3627_outdated_urls_security_page_spec.rb | 31 +++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20210726065124_issue_3627_outdated_urls_security_page.rb create mode 100644 spec/db/migrate/issue_3627_outdated_urls_security_page_spec.rb diff --git a/db/migrate/20170713000001_omniauth_office365_setting.rb b/db/migrate/20170713000001_omniauth_office365_setting.rb index e060dbc52..337ea8ecf 100644 --- a/db/migrate/20170713000001_omniauth_office365_setting.rb +++ b/db/migrate/20170713000001_omniauth_office365_setting.rb @@ -29,7 +29,7 @@ class OmniauthOffice365Setting < ActiveRecord::Migration[4.2] controller: 'SettingsAreaSwitch', sub: ['auth_microsoft_office365_credentials'], title_i18n: ['Office 365'], - description_i18n: ['Office 365', 'Microsoft Application Registration Portal', 'https://apps.dev.microsoft.com'], + description_i18n: ['Office 365', 'Microsoft Application Registration Portal', 'https://portal.azure.com'], permission: ['admin.security'], }, state: false, diff --git a/db/migrate/20210726065124_issue_3627_outdated_urls_security_page.rb b/db/migrate/20210726065124_issue_3627_outdated_urls_security_page.rb new file mode 100644 index 000000000..06da51cc2 --- /dev/null +++ b/db/migrate/20210726065124_issue_3627_outdated_urls_security_page.rb @@ -0,0 +1,15 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +class Issue3627OutdatedUrlsSecurityPage < ActiveRecord::Migration[6.0] + def change + return if !Setting.exists?(name: 'system_init_done') + + setting = Setting.find_by name: 'auth_google_oauth2' + setting.preferences[:description_i18n][2] = 'https://console.cloud.google.com/apis/credentials' + setting.save! + + setting = Setting.find_by name: 'auth_microsoft_office365' + setting.preferences[:description_i18n][2] = 'https://portal.azure.com' + setting.save! + end +end diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index 6f3a6a26c..4ce862d11 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -1315,7 +1315,7 @@ Setting.create_if_not_exists( controller: 'SettingsAreaSwitch', sub: ['auth_google_oauth2_credentials'], title_i18n: ['Google'], - description_i18n: ['Google', 'Google API Console Site', 'https://console.developers.google.com/apis/credentials'], + description_i18n: ['Google', 'Google API Console Site', 'https://console.cloud.google.com/apis/credentials'], permission: ['admin.security'], }, state: false, @@ -1550,7 +1550,7 @@ Setting.create_if_not_exists( controller: 'SettingsAreaSwitch', sub: ['auth_microsoft_office365_credentials'], title_i18n: ['Office 365'], - description_i18n: ['Office 365', 'Microsoft Application Registration Portal', 'https://apps.dev.microsoft.com'], + description_i18n: ['Office 365', 'Microsoft Application Registration Portal', 'https://portal.azure.com'], permission: ['admin.security'], }, state: false, diff --git a/spec/db/migrate/issue_3627_outdated_urls_security_page_spec.rb b/spec/db/migrate/issue_3627_outdated_urls_security_page_spec.rb new file mode 100644 index 000000000..87dcb271e --- /dev/null +++ b/spec/db/migrate/issue_3627_outdated_urls_security_page_spec.rb @@ -0,0 +1,31 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe Issue3627OutdatedUrlsSecurityPage, type: :db_migration do + context 'when having outadted url for google oauth2' do + before do + setting.preferences[:description_i18n][2] = 'https://console.developers.google.com/apis/credentials' + setting.save! + end + + let(:setting) { Setting.find_by(name: 'auth_google_oauth2') } + + it 'change url in preference description placeholder' do + expect { migrate }.to change { setting.reload.preferences[:description_i18n][2] }.to('https://console.cloud.google.com/apis/credentials') + end + end + + context 'when having outadted url for microsoft office365' do + before do + setting.preferences[:description_i18n][2] = 'https://apps.dev.microsoft.com' + setting.save! + end + + let(:setting) { Setting.find_by(name: 'auth_microsoft_office365') } + + it 'change url in preference description placeholder' do + expect { migrate }.to change { setting.reload.preferences[:description_i18n][2] }.to('https://portal.azure.com') + end + end +end