diff options
author | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-10-19 05:55:06 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-10-19 05:55:06 +0000 |
commit | 880792a04eaed2409019d54961ecddd402d8471c (patch) | |
tree | 34bf5426273928cb20dd91913854dfb216c55fa3 /spec | |
parent | b9cb0e1632d21860f0e36dc970e3318da632330f (diff) | |
download | gitlab-ce-880792a04eaed2409019d54961ecddd402d8471c.tar.gz |
Catch `RedirectionTooDeep` Exception in webhooks
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/http_spec.rb | 26 | ||||
-rw-r--r-- | spec/services/web_hook_service_spec.rb | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/spec/lib/gitlab/http_spec.rb b/spec/lib/gitlab/http_spec.rb index d0dadfa78da..6c37c157f5d 100644 --- a/spec/lib/gitlab/http_spec.rb +++ b/spec/lib/gitlab/http_spec.rb @@ -46,4 +46,30 @@ describe Gitlab::HTTP do end end end + + describe 'handle redirect loops' do + before do + WebMock.stub_request(:any, "http://example.org").to_raise(HTTParty::RedirectionTooDeep.new("Redirection Too Deep")) + end + + it 'handles GET requests' do + expect { described_class.get('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) + end + + it 'handles POST requests' do + expect { described_class.post('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) + end + + it 'handles PUT requests' do + expect { described_class.put('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) + end + + it 'handles DELETE requests' do + expect { described_class.delete('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) + end + + it 'handles HEAD requests' do + expect { described_class.head('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) + end + end end diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index 622e56e1da5..b1cc6d2eb83 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -97,7 +97,7 @@ describe WebHookService do end it 'handles exceptions' do - exceptions = [SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError] + exceptions = [SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep] exceptions.each do |exception_class| exception = exception_class.new('Exception message') |