proxy_spec.rb 3.7 KB

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