proxy_spec.rb 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Settings > System > Network', type: :system do
  4. before { visit 'settings/system' }
  5. let(:proxy) { ENV['ZAMMAD_PROXY'] }
  6. let(:proxy_username) { ENV['ZAMMAD_PROXY_USERNAME'] }
  7. let(:proxy_password) { ENV['ZAMMAD_PROXY_PASSWORD'] }
  8. describe 'configure proxy setting' do
  9. it 'test proxy settings with correct config' do
  10. within(:active_content) do
  11. click(:href, '#network')
  12. fill_in 'proxy', with: proxy
  13. fill_in 'proxy_username', with: proxy_username
  14. fill_in 'proxy_password', with: proxy_password
  15. click_on 'Test Connection'
  16. expect(page).to have_button('Test Connection', visible: :hidden, wait: 5)
  17. expect(page).to have_button('Submit', visible: :visible, wait: 5)
  18. find('.js-submit:not(.hide)').click
  19. expect(page).to have_button('Submit', visible: :hidden, wait: 5)
  20. expect(page).to have_button('Test Connection', visible: :visible, wait: 5)
  21. end
  22. end
  23. context 'test proxy settings when invalid config is used' do
  24. it 'with invalid proxy' do
  25. within(:active_content) do
  26. click(:href, '#network')
  27. fill_in 'proxy', with: 'invalid_proxy'
  28. fill_in 'proxy_username', with: proxy_username
  29. fill_in 'proxy_password', with: proxy_password
  30. click_on 'Test Connection'
  31. expect(page).to have_css('h1.modal-title', text: 'Error', wait: 5)
  32. expect(page).to have_css('div.modal-body', text: %r{Invalid proxy address}, wait: 5)
  33. expect(page).to have_button('Test Connection', visible: :visible, wait: 5)
  34. expect(page).to have_button('Submit', visible: :hidden, wait: 5)
  35. end
  36. end
  37. it 'with unknown proxy' do
  38. within(:active_content) do
  39. click(:href, '#network')
  40. fill_in 'proxy', with: 'proxy.example.com:3128'
  41. fill_in 'proxy_username', with: proxy_username
  42. fill_in 'proxy_password', with: proxy_password
  43. click_on 'Test Connection'
  44. expect(page).to have_css('h1.modal-title', text: 'Error', wait: 5)
  45. expect(page).to have_css('div.modal-body', text: %r{Failed to open TCP connection}, wait: 5)
  46. expect(page).to have_button('Test Connection', visible: :visible, wait: 5)
  47. expect(page).to have_button('Submit', visible: :hidden, wait: 5)
  48. end
  49. end
  50. it 'with invalid proxy username' do
  51. within(:active_content) do
  52. click(:href, '#network')
  53. fill_in 'proxy', with: proxy
  54. fill_in 'proxy_username', with: 'invalid_username'
  55. fill_in 'proxy_password', with: proxy_password
  56. click_on 'Test Connection'
  57. expect(page).to have_css('h1.modal-title', text: 'Error', wait: 5)
  58. expect(page).to have_css('div.modal-body', text: %r{Access Denied}, wait: 5)
  59. expect(page).to have_button('Test Connection', visible: :visible, wait: 5)
  60. expect(page).to have_button('Submit', visible: :hidden, wait: 5)
  61. end
  62. end
  63. it 'with invalid proxy password' do
  64. within(:active_content) do
  65. click(:href, '#network')
  66. fill_in 'proxy', with: proxy
  67. fill_in 'proxy_username', with: proxy_username
  68. fill_in 'proxy_password', with: 'invalid_password'
  69. click_on 'Test Connection'
  70. expect(page).to have_css('h1.modal-title', text: 'Error', wait: 5)
  71. expect(page).to have_css('div.modal-body', text: %r{Access Denied}, wait: 5)
  72. expect(page).to have_button('Test Connection', visible: :visible, wait: 5)
  73. expect(page).to have_button('Submit', visible: :hidden, wait: 5)
  74. end
  75. end
  76. end
  77. end
  78. end