Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
880792a0
Commit
880792a0
authored
Oct 19, 2018
by
Heinrich Lee Yu
Committed by
Stan Hu
Oct 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch `RedirectionTooDeep` Exception in webhooks
parent
b9cb0e16
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
2 deletions
+40
-2
app/services/web_hook_service.rb
app/services/web_hook_service.rb
+1
-1
changelogs/unreleased/52692-catch-redirect-loops.yml
changelogs/unreleased/52692-catch-redirect-loops.yml
+5
-0
lib/gitlab/http.rb
lib/gitlab/http.rb
+7
-0
spec/lib/gitlab/http_spec.rb
spec/lib/gitlab/http_spec.rb
+26
-0
spec/services/web_hook_service_spec.rb
spec/services/web_hook_service_spec.rb
+1
-1
No files found.
app/services/web_hook_service.rb
View file @
880792a0
...
...
@@ -43,7 +43,7 @@ class WebHookService
http_status:
response
.
code
,
message:
response
.
to_s
}
rescue
SocketError
,
OpenSSL
::
SSL
::
SSLError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Errno
::
EHOSTUNREACH
,
Net
::
OpenTimeout
,
Net
::
ReadTimeout
,
Gitlab
::
HTTP
::
BlockedUrlError
=>
e
rescue
SocketError
,
OpenSSL
::
SSL
::
SSLError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Errno
::
EHOSTUNREACH
,
Net
::
OpenTimeout
,
Net
::
ReadTimeout
,
Gitlab
::
HTTP
::
BlockedUrlError
,
Gitlab
::
HTTP
::
RedirectionTooDeep
=>
e
log_execution
(
trigger:
hook_name
,
url:
hook
.
url
,
...
...
changelogs/unreleased/52692-catch-redirect-loops.yml
0 → 100644
View file @
880792a0
---
title
:
Fix 500 error when testing webhooks with redirect loops
merge_request
:
22447
author
:
Heinrich Lee Yu
type
:
fixed
lib/gitlab/http.rb
View file @
880792a0
...
...
@@ -5,9 +5,16 @@
module
Gitlab
class
HTTP
BlockedUrlError
=
Class
.
new
(
StandardError
)
RedirectionTooDeep
=
Class
.
new
(
StandardError
)
include
HTTParty
# rubocop:disable Gitlab/HTTParty
connection_adapter
ProxyHTTPConnectionAdapter
def
self
.
perform_request
(
http_method
,
path
,
options
,
&
block
)
super
rescue
HTTParty
::
RedirectionTooDeep
raise
RedirectionTooDeep
end
end
end
spec/lib/gitlab/http_spec.rb
View file @
880792a0
...
...
@@ -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
spec/services/web_hook_service_spec.rb
View file @
880792a0
...
...
@@ -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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment