PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/features/admin/admin_settings_spec.rb

https://gitlab.com/beverett/gitlab-ce
Ruby | 284 lines | 229 code | 55 blank | 0 comment | 0 complexity | a22af9e315706c12706e5d000c8e196d MD5 | raw file
  1. require 'spec_helper'
  2. feature 'Admin updates settings' do
  3. include StubENV
  4. before do
  5. stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
  6. sign_in(create(:admin))
  7. visit admin_application_settings_path
  8. end
  9. scenario 'Change visibility settings' do
  10. page.within('.as-visibility-access') do
  11. choose "application_setting_default_project_visibility_20"
  12. click_button 'Save changes'
  13. end
  14. expect(page).to have_content "Application settings saved successfully"
  15. end
  16. scenario 'Uncheck all restricted visibility levels' do
  17. page.within('.as-visibility-access') do
  18. find('#application_setting_visibility_level_0').set(false)
  19. find('#application_setting_visibility_level_10').set(false)
  20. find('#application_setting_visibility_level_20').set(false)
  21. click_button 'Save changes'
  22. end
  23. expect(page).to have_content "Application settings saved successfully"
  24. expect(find('#application_setting_visibility_level_0')).not_to be_checked
  25. expect(find('#application_setting_visibility_level_10')).not_to be_checked
  26. expect(find('#application_setting_visibility_level_20')).not_to be_checked
  27. end
  28. scenario 'Modify import sources' do
  29. expect(Gitlab::CurrentSettings.import_sources).not_to be_empty
  30. page.within('.as-visibility-access') do
  31. Gitlab::ImportSources.options.map do |name, _|
  32. uncheck name
  33. end
  34. click_button 'Save changes'
  35. end
  36. expect(page).to have_content "Application settings saved successfully"
  37. expect(Gitlab::CurrentSettings.import_sources).to be_empty
  38. page.within('.as-visibility-access') do
  39. check "Repo by URL"
  40. click_button 'Save changes'
  41. end
  42. expect(page).to have_content "Application settings saved successfully"
  43. expect(Gitlab::CurrentSettings.import_sources).to eq(['git'])
  44. end
  45. scenario 'Change Visibility and Access Controls' do
  46. page.within('.as-visibility-access') do
  47. uncheck 'Project export enabled'
  48. click_button 'Save changes'
  49. end
  50. expect(Gitlab::CurrentSettings.project_export_enabled).to be_falsey
  51. expect(page).to have_content "Application settings saved successfully"
  52. end
  53. scenario 'Change Account and Limit Settings' do
  54. page.within('.as-account-limit') do
  55. uncheck 'Gravatar enabled'
  56. click_button 'Save changes'
  57. end
  58. expect(Gitlab::CurrentSettings.gravatar_enabled).to be_falsey
  59. expect(page).to have_content "Application settings saved successfully"
  60. end
  61. scenario 'Change Sign-in restrictions' do
  62. page.within('.as-signin') do
  63. fill_in 'Home page URL', with: 'https://about.gitlab.com/'
  64. click_button 'Save changes'
  65. end
  66. expect(Gitlab::CurrentSettings.home_page_url).to eq "https://about.gitlab.com/"
  67. expect(page).to have_content "Application settings saved successfully"
  68. end
  69. scenario 'Modify oauth providers' do
  70. expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to be_empty
  71. page.within('.as-signin') do
  72. uncheck 'Google'
  73. click_button 'Save changes'
  74. end
  75. expect(page).to have_content "Application settings saved successfully"
  76. expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include('google_oauth2')
  77. page.within('.as-signin') do
  78. check "Google"
  79. click_button 'Save changes'
  80. end
  81. expect(page).to have_content "Application settings saved successfully"
  82. expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).not_to include('google_oauth2')
  83. end
  84. scenario 'Change Help page' do
  85. page.within('.as-help-page') do
  86. fill_in 'Help page text', with: 'Example text'
  87. check 'Hide marketing-related entries from help'
  88. fill_in 'Support page URL', with: 'http://example.com/help'
  89. click_button 'Save changes'
  90. end
  91. expect(Gitlab::CurrentSettings.help_page_text).to eq "Example text"
  92. expect(Gitlab::CurrentSettings.help_page_hide_commercial_content).to be_truthy
  93. expect(Gitlab::CurrentSettings.help_page_support_url).to eq "http://example.com/help"
  94. expect(page).to have_content "Application settings saved successfully"
  95. end
  96. scenario 'Change Pages settings' do
  97. page.within('.as-pages') do
  98. fill_in 'Maximum size of pages (MB)', with: 15
  99. check 'Require users to prove ownership of custom domains'
  100. click_button 'Save changes'
  101. end
  102. expect(Gitlab::CurrentSettings.max_pages_size).to eq 15
  103. expect(Gitlab::CurrentSettings.pages_domain_verification_enabled?).to be_truthy
  104. expect(page).to have_content "Application settings saved successfully"
  105. end
  106. scenario 'Change CI/CD settings' do
  107. page.within('.as-ci-cd') do
  108. check 'Enabled Auto DevOps (Beta) for projects by default'
  109. fill_in 'Auto devops domain', with: 'domain.com'
  110. click_button 'Save changes'
  111. end
  112. expect(Gitlab::CurrentSettings.auto_devops_enabled?).to be true
  113. expect(Gitlab::CurrentSettings.auto_devops_domain).to eq('domain.com')
  114. expect(page).to have_content "Application settings saved successfully"
  115. end
  116. scenario 'Change Influx settings' do
  117. page.within('.as-influx') do
  118. check 'Enable InfluxDB Metrics'
  119. click_button 'Save changes'
  120. end
  121. expect(Gitlab::CurrentSettings.metrics_enabled?).to be true
  122. expect(page).to have_content "Application settings saved successfully"
  123. end
  124. scenario 'Change Prometheus settings' do
  125. page.within('.as-prometheus') do
  126. check 'Enable Prometheus Metrics'
  127. click_button 'Save changes'
  128. end
  129. expect(Gitlab::CurrentSettings.prometheus_metrics_enabled?).to be true
  130. expect(page).to have_content "Application settings saved successfully"
  131. end
  132. scenario 'Change Performance bar settings' do
  133. group = create(:group)
  134. page.within('.as-performance-bar') do
  135. check 'Enable the Performance Bar'
  136. fill_in 'Allowed group', with: group.path
  137. click_on 'Save changes'
  138. end
  139. expect(page).to have_content "Application settings saved successfully"
  140. expect(find_field('Enable the Performance Bar')).to be_checked
  141. expect(find_field('Allowed group').value).to eq group.path
  142. page.within('.as-performance-bar') do
  143. uncheck 'Enable the Performance Bar'
  144. click_on 'Save changes'
  145. end
  146. expect(page).to have_content 'Application settings saved successfully'
  147. expect(find_field('Enable the Performance Bar')).not_to be_checked
  148. expect(find_field('Allowed group').value).to be_nil
  149. end
  150. scenario 'Change Background jobs settings' do
  151. page.within('.as-background') do
  152. fill_in 'Throttling Factor', with: 1
  153. click_button 'Save changes'
  154. end
  155. expect(Gitlab::CurrentSettings.sidekiq_throttling_factor).to eq(1)
  156. expect(page).to have_content "Application settings saved successfully"
  157. end
  158. scenario 'Change Spam settings' do
  159. page.within('.as-spam') do
  160. check 'Enable reCAPTCHA'
  161. fill_in 'reCAPTCHA Site Key', with: 'key'
  162. fill_in 'reCAPTCHA Private Key', with: 'key'
  163. fill_in 'IPs per user', with: 15
  164. click_button 'Save changes'
  165. end
  166. expect(page).to have_content "Application settings saved successfully"
  167. expect(Gitlab::CurrentSettings.recaptcha_enabled).to be true
  168. expect(Gitlab::CurrentSettings.unique_ips_limit_per_user).to eq(15)
  169. end
  170. scenario 'Configure web terminal' do
  171. page.within('.as-terminal') do
  172. fill_in 'Max session time', with: 15
  173. click_button 'Save changes'
  174. end
  175. expect(page).to have_content "Application settings saved successfully"
  176. expect(Gitlab::CurrentSettings.terminal_max_session_time).to eq(15)
  177. end
  178. scenario 'Enable outbound requests' do
  179. page.within('.as-outbound') do
  180. check 'Allow requests to the local network from hooks and services'
  181. click_button 'Save changes'
  182. end
  183. expect(page).to have_content "Application settings saved successfully"
  184. expect(Gitlab::CurrentSettings.allow_local_requests_from_hooks_and_services).to be true
  185. end
  186. scenario 'Change Slack Notifications Service template settings' do
  187. first(:link, 'Service Templates').click
  188. click_link 'Slack notifications'
  189. fill_in 'Webhook', with: 'http://localhost'
  190. fill_in 'Username', with: 'test_user'
  191. fill_in 'service_push_channel', with: '#test_channel'
  192. page.check('Notify only broken pipelines')
  193. page.check('Notify only default branch')
  194. check_all_events
  195. click_on 'Save'
  196. expect(page).to have_content 'Application settings saved successfully'
  197. click_link 'Slack notifications'
  198. page.all('input[type=checkbox]').each do |checkbox|
  199. expect(checkbox).to be_checked
  200. end
  201. expect(find_field('Webhook').value).to eq 'http://localhost'
  202. expect(find_field('Username').value).to eq 'test_user'
  203. expect(find('#service_push_channel').value).to eq '#test_channel'
  204. end
  205. scenario 'Change Keys settings' do
  206. page.within('.as-visibility-access') do
  207. select 'Are forbidden', from: 'RSA SSH keys'
  208. select 'Are allowed', from: 'DSA SSH keys'
  209. select 'Must be at least 384 bits', from: 'ECDSA SSH keys'
  210. select 'Are forbidden', from: 'ED25519 SSH keys'
  211. click_on 'Save changes'
  212. end
  213. forbidden = ApplicationSetting::FORBIDDEN_KEY_VALUE.to_s
  214. expect(page).to have_content 'Application settings saved successfully'
  215. expect(find_field('RSA SSH keys').value).to eq(forbidden)
  216. expect(find_field('DSA SSH keys').value).to eq('0')
  217. expect(find_field('ECDSA SSH keys').value).to eq('384')
  218. expect(find_field('ED25519 SSH keys').value).to eq(forbidden)
  219. end
  220. def check_all_events
  221. page.check('Active')
  222. page.check('Push')
  223. page.check('Tag push')
  224. page.check('Note')
  225. page.check('Issue')
  226. page.check('Merge request')
  227. page.check('Pipeline')
  228. end
  229. end