diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index 6592e9d78..769650e1b 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -69,7 +69,6 @@ if [ "$LEVEL" == '1' ]; then rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_token_access_test.rb rm test/browser/reporting_test.rb - rm test/browser/setting_test.rb # test/browser/swich_to_user_test.rb # test/browser/taskbar_session_test.rb # test/browser/taskbar_task_test.rb @@ -141,7 +140,6 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_token_access_test.rb rm test/browser/reporting_test.rb - rm test/browser/setting_test.rb rm test/browser/switch_to_user_test.rb rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_task_test.rb @@ -213,7 +211,6 @@ elif [ "$LEVEL" == '3' ]; then rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_token_access_test.rb rm test/browser/reporting_test.rb - rm test/browser/setting_test.rb rm test/browser/switch_to_user_test.rb rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_task_test.rb @@ -285,7 +282,6 @@ elif [ "$LEVEL" == '4' ]; then rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_token_access_test.rb rm test/browser/reporting_test.rb - rm test/browser/setting_test.rb rm test/browser/switch_to_user_test.rb rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_task_test.rb @@ -356,7 +352,6 @@ elif [ "$LEVEL" == '5' ]; then rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_token_access_test.rb rm test/browser/reporting_test.rb - rm test/browser/setting_test.rb rm test/browser/switch_to_user_test.rb rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_task_test.rb @@ -430,7 +425,6 @@ elif [ "$LEVEL" == '6' ]; then # test/browser/preferences_permission_check_test.rb # test/browser/preferences_token_access_test.rb # test/browser/reporting_test.rb - # test/browser/setting_test.rb rm test/browser/switch_to_user_test.rb rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_task_test.rb diff --git a/spec/system/settings/branding_spec.rb b/spec/system/settings/branding_spec.rb new file mode 100644 index 000000000..a4a2b569a --- /dev/null +++ b/spec/system/settings/branding_spec.rb @@ -0,0 +1,22 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe 'Manage > Settings > Branding', type: :system do + context 'when branding product name is changed' do + before { visit '/#settings/branding' } + + let(:new_name) { 'ABC App' } + + it 'shows the new name in the page title' do + within :active_content do + within '#product_name' do + fill_in 'product_name', with: new_name + click_on 'Submit' + end + end + + expect(page).to have_title("#{new_name} - Branding") + end + end +end diff --git a/spec/system/settings/security_spec.rb b/spec/system/settings/security_spec.rb new file mode 100644 index 000000000..b5ac89cab --- /dev/null +++ b/spec/system/settings/security_spec.rb @@ -0,0 +1,151 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe 'Manage > Settings > Security', type: :system do + describe 'configure third-party applications' do + shared_examples 'for third-party applications button in login page' do + context 'for third-party applications button in login page', authenticated_as: false do + before { visit 'login' } + + context 'when feature is on' do + before { Setting.set(app_setting, true) } + + it 'has authentication button in login page' do + expect(page).to have_button(app_name) + end + end + + context 'when feature is off' do + before { Setting.set(app_setting, false) } + + it 'does not have authentication button in login page' do + expect(page).to have_no_button(app_name) + end + end + end + end + + shared_examples 'for third-party applications settings' do + context 'for third-party applications settings', authenticated_as: true do + let(:app_checkbox) { "setting-#{app_setting}" } + + context 'when app is turned on in setting page' do + before do + Setting.set(app_setting, false) + visit '/#settings/security' + + within :active_content do + click 'a[href="#third_party_auth"]' + end + + check app_checkbox, { allow_label_click: true } + await_empty_ajax_queue + end + + it 'sets settings to be true' do + expect(Setting.get(app_setting)).to be_truthy + end + end + + context 'when app is turned off in setting page' do + before do + Setting.set(app_setting, true) + visit '/#settings/security' + + within :active_content do + click 'a[href="#third_party_auth"]' + end + + uncheck app_checkbox, { allow_label_click: true } + await_empty_ajax_queue + end + + it 'sets settings to be false' do + expect(Setting.get(app_setting)).to be_falsey + end + end + end + end + + describe 'Authentication via Facebook' do + let(:app_name) { 'Facebook' } + let(:app_setting) { 'auth_facebook' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via Github' do + let(:app_name) { 'GitHub' } + let(:app_setting) { 'auth_github' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via GitLab' do + let(:app_name) { 'GitLab' } + let(:app_setting) { 'auth_gitlab' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via Google' do + let(:app_name) { 'Google' } + let(:app_setting) { 'auth_google_oauth2' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via LinkedIn' do + let(:app_name) { 'LinkedIn' } + let(:app_setting) { 'auth_linkedin' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via Office 365' do + let(:app_name) { 'Office 365' } + let(:app_setting) { 'auth_microsoft_office365' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via SAML' do + let(:app_name) { 'SAML' } + let(:app_setting) { 'auth_saml' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via SSO' do + let(:app_name) { 'SSO' } + let(:app_setting) { 'auth_sso' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via Twitter' do + let(:app_name) { 'Twitter' } + let(:app_setting) { 'auth_twitter' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + + describe 'Authentication via Weibo' do + let(:app_name) { 'Weibo' } + let(:app_setting) { 'auth_weibo' } + + include_examples 'for third-party applications button in login page' + include_examples 'for third-party applications settings' + end + end +end diff --git a/test/browser/setting_test.rb b/test/browser/setting_test.rb deleted file mode 100644 index 2b588900e..000000000 --- a/test/browser/setting_test.rb +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ - -require 'browser_test_helper' - -class SettingTest < TestCase - def test_setting - @browser = browser_instance - login( - username: 'admin@example.com', - password: 'test', - url: browser_url, - ) - tasks_close_all - - # make sure, that we have english frontend - click(css: 'a[href="#current_user"]') - click(css: 'a[href="#profile"]') - click(css: 'a[href="#profile/language"]') - select( - css: '.js-language [name="locale"]', - value: 'English (United States)', - ) - click(css: '.content.active button[type="submit"]') - sleep 2 - - # change settings - click(css: 'a[href="#manage"]') - click(css: 'a[href="#settings/security"]') - click(css: 'a[href="#third_party_auth"]') - sleep 2 - switch( - css: '.content.active .js-setting[data-name="auth_facebook"]', - type: 'off', - ) - - browser2 = browser_instance - location( - browser: browser2, - url: browser_url, - ) - watch_for( - browser: browser2, - css: 'body', - value: 'login', - ) - match_not( - browser: browser2, - css: 'body', - value: 'facebook', - ) - - # set yes - switch( - css: '.content.active .js-setting[data-name="auth_facebook"]', - type: 'on', - ) - - # set key and secret - set( - css: '[data-name="auth_facebook_credentials"] input[name=app_id]', - value: 'id_test1234äöüß', - ) - set( - css: '[data-name="auth_facebook_credentials"] input[name=app_secret]', - value: 'secret_test1234äöüß', - ) - click(css: '[data-name="auth_facebook_credentials"] button[type=submit]') - watch_for( - css: '#notify', - value: 'update successful', - ) - sleep 4 - match( - css: '[data-name="auth_facebook_credentials"] input[name=app_id]', - value: 'id_test1234äöüß', - ) - match( - css: '[data-name="auth_facebook_credentials"] input[name=app_secret]', - value: 'secret_test1234äöüß', - ) - - # verify login page - sleep 2 - watch_for( - browser: browser2, - css: 'body', - value: 'facebook', - ) - - # set key and secret again - set( - css: '[data-name="auth_facebook_credentials"] input[name=app_id]', - value: '---', - ) - set( - css: '[data-name="auth_facebook_credentials"] input[name=app_secret]', - value: '---', - ) - click(css: '[data-name="auth_facebook_credentials"] button[type=submit]') - watch_for( - css: '#notify', - value: 'update successful', - ) - sleep 4 - match( - css: '[data-name="auth_facebook_credentials"] input[name=app_id]', - value: '---', - ) - match( - css: '[data-name="auth_facebook_credentials"] input[name=app_secret]', - value: '---', - ) - - reload - - click(css: 'a[href="#settings/security"]') - click(css: 'a[href="#third_party_auth"]') - watch_for( - css: '[data-name="auth_facebook_credentials"] input[name=app_id]', - value: '---', - ) - watch_for( - css: '[data-name="auth_facebook_credentials"] input[name=app_secret]', - value: '---', - ) - sleep 2 - switch( - css: '.content.active .js-setting[data-name="auth_facebook"]', - type: 'off', - ) - - sleep 2 - watch_for( - browser: browser2, - css: 'body', - value: 'login', - ) - match_not( - browser: browser2, - css: 'body', - value: 'facebook', - ) - end - - def test_product_name - @browser = browser_instance - login( - username: 'admin@example.com', - password: 'test', - url: browser_url, - ) - tasks_close_all - - verify_title(value: 'Zammad Test System') - - click(css: 'a[href="#manage"]') - click(css: '.content.active a[href="#settings/branding"]') - set( - css: '.content.active [name="product_name"]', - value: 'ABC App', - ) - click(css: '.content.active #product_name button[type=submit]') - - sleep 2 - verify_title(value: 'ABC App') - set( - css: '.content.active [name="product_name"]', - value: 'Zammad Test System', - ) - click(css: '.content.active #product_name button[type=submit]') - - sleep 2 - verify_title(value: 'Zammad Test System') - end - -end