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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
949a7e8e
Commit
949a7e8e
authored
Dec 07, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'report-ssl-errors' of
https://gitlab.com/stanhu/gitlab-ce
parents
c823e85d
ba3c7020
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
23 deletions
+29
-23
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+2
-3
app/models/hooks/web_hook.rb
app/models/hooks/web_hook.rb
+19
-17
features/steps/project/hooks.rb
features/steps/project/hooks.rb
+1
-3
spec/models/hooks/web_hook_spec.rb
spec/models/hooks/web_hook_spec.rb
+6
-0
No files found.
CHANGELOG
View file @
949a7e8e
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.3.0 (unreleased)
v 8.3.0 (unreleased)
- Fix API setting of 'public' attribute to false will make a project private (Stan Hu)
- Fix API setting of 'public' attribute to false will make a project private (Stan Hu)
- Handle and report SSL errors in Web hook test (Stan Hu)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Fix 500 error when update group member permission
- Fix 500 error when update group member permission
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
...
...
app/controllers/projects/hooks_controller.rb
View file @
949a7e8e
...
@@ -25,13 +25,12 @@ class Projects::HooksController < Projects::ApplicationController
...
@@ -25,13 +25,12 @@ class Projects::HooksController < Projects::ApplicationController
def
test
def
test
if
!
@project
.
empty_repo?
if
!
@project
.
empty_repo?
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
status
,
message
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
flash
[
:notice
]
=
'Hook successfully executed.'
else
else
flash
[
:alert
]
=
'Hook execution failed. '
\
flash
[
:alert
]
=
"Hook execution failed:
#{
message
}
"
'Ensure hook URL is correct and service is up.'
end
end
else
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
...
...
app/models/hooks/web_hook.rb
View file @
949a7e8e
...
@@ -37,7 +37,7 @@ class WebHook < ActiveRecord::Base
...
@@ -37,7 +37,7 @@ class WebHook < ActiveRecord::Base
def
execute
(
data
,
hook_name
)
def
execute
(
data
,
hook_name
)
parsed_url
=
URI
.
parse
(
url
)
parsed_url
=
URI
.
parse
(
url
)
if
parsed_url
.
userinfo
.
blank?
if
parsed_url
.
userinfo
.
blank?
WebHook
.
post
(
url
,
response
=
WebHook
.
post
(
url
,
body:
data
.
to_json
,
body:
data
.
to_json
,
headers:
{
headers:
{
"Content-Type"
=>
"application/json"
,
"Content-Type"
=>
"application/json"
,
...
@@ -50,7 +50,7 @@ class WebHook < ActiveRecord::Base
...
@@ -50,7 +50,7 @@ class WebHook < ActiveRecord::Base
username:
URI
.
decode
(
parsed_url
.
user
),
username:
URI
.
decode
(
parsed_url
.
user
),
password:
URI
.
decode
(
parsed_url
.
password
),
password:
URI
.
decode
(
parsed_url
.
password
),
}
}
WebHook
.
post
(
post_url
,
response
=
WebHook
.
post
(
post_url
,
body:
data
.
to_json
,
body:
data
.
to_json
,
headers:
{
headers:
{
"Content-Type"
=>
"application/json"
,
"Content-Type"
=>
"application/json"
,
...
@@ -59,9 +59,11 @@ class WebHook < ActiveRecord::Base
...
@@ -59,9 +59,11 @@ class WebHook < ActiveRecord::Base
verify:
enable_ssl_verification
,
verify:
enable_ssl_verification
,
basic_auth:
auth
)
basic_auth:
auth
)
end
end
rescue
SocketError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Net
::
OpenTimeout
=>
e
[
response
.
code
==
200
,
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
response
.
to_s
)]
rescue
SocketError
,
OpenSSL
::
SSL
::
SSLError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Net
::
OpenTimeout
=>
e
logger
.
error
(
"WebHook Error =>
#{
e
}
"
)
logger
.
error
(
"WebHook Error =>
#{
e
}
"
)
false
[
false
,
e
.
to_s
]
end
end
def
async_execute
(
data
,
hook_name
)
def
async_execute
(
data
,
hook_name
)
...
...
features/steps/project/hooks.rb
View file @
949a7e8e
...
@@ -70,8 +70,6 @@ class Spinach::Features::ProjectHooks < Spinach::FeatureSteps
...
@@ -70,8 +70,6 @@ class Spinach::Features::ProjectHooks < Spinach::FeatureSteps
step
'I should see hook service down error message'
do
step
'I should see hook service down error message'
do
expect
(
page
).
to
have_selector
'.flash-alert'
,
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed. '
\
text:
'Hook execution failed: Exception from'
'Ensure hook URL is correct and '
\
'service is up.'
end
end
end
end
spec/models/hooks/web_hook_spec.rb
View file @
949a7e8e
...
@@ -71,5 +71,11 @@ describe ProjectHook do
...
@@ -71,5 +71,11 @@ describe ProjectHook do
expect
{
@project_hook
.
execute
(
@data
,
'push_hooks'
)
}.
to
raise_error
(
RuntimeError
)
expect
{
@project_hook
.
execute
(
@data
,
'push_hooks'
)
}.
to
raise_error
(
RuntimeError
)
end
end
it
"handles SSL exceptions"
do
expect
(
WebHook
).
to
receive
(
:post
).
and_raise
(
OpenSSL
::
SSL
::
SSLError
.
new
(
'SSL error'
))
expect
(
@project_hook
.
execute
(
@data
,
'push_hooks'
)).
to
eq
([
false
,
'SSL error'
])
end
end
end
end
end
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