Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
949a7e8e
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
949a7e8e
编写于
12月 07, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'report-ssl-errors' of
https://gitlab.com/stanhu/gitlab-ce
上级
c823e85d
ba3c7020
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
23 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
949a7e8e
...
...
@@ -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)
- 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 500 error when update group member permission
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
...
...
app/controllers/projects/hooks_controller.rb
浏览文件 @
949a7e8e
...
...
@@ -25,13 +25,12 @@ class Projects::HooksController < Projects::ApplicationController
def
test
if
!
@project
.
empty_repo?
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
status
,
message
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
else
flash
[
:alert
]
=
'Hook execution failed. '
\
'Ensure hook URL is correct and service is up.'
flash
[
:alert
]
=
"Hook execution failed:
#{
message
}
"
end
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
...
...
app/models/hooks/web_hook.rb
浏览文件 @
949a7e8e
...
...
@@ -37,31 +37,33 @@ class WebHook < ActiveRecord::Base
def
execute
(
data
,
hook_name
)
parsed_url
=
URI
.
parse
(
url
)
if
parsed_url
.
userinfo
.
blank?
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
,
"X-Gitlab-Event"
=>
hook_name
.
singularize
.
titleize
},
verify:
enable_ssl_verification
)
response
=
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
,
"X-Gitlab-Event"
=>
hook_name
.
singularize
.
titleize
},
verify:
enable_ssl_verification
)
else
post_url
=
url
.
gsub
(
"
#{
parsed_url
.
userinfo
}
@"
,
""
)
auth
=
{
username:
URI
.
decode
(
parsed_url
.
user
),
password:
URI
.
decode
(
parsed_url
.
password
),
}
WebHook
.
post
(
post_url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
,
"X-Gitlab-Event"
=>
hook_name
.
singularize
.
titleize
},
verify:
enable_ssl_verification
,
basic_auth:
auth
)
response
=
WebHook
.
post
(
post_url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
,
"X-Gitlab-Event"
=>
hook_name
.
singularize
.
titleize
},
verify:
enable_ssl_verification
,
basic_auth:
auth
)
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
}
"
)
false
[
false
,
e
.
to_s
]
end
def
async_execute
(
data
,
hook_name
)
...
...
features/steps/project/hooks.rb
浏览文件 @
949a7e8e
...
...
@@ -70,8 +70,6 @@ class Spinach::Features::ProjectHooks < Spinach::FeatureSteps
step
'I should see hook service down error message'
do
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed. '
\
'Ensure hook URL is correct and '
\
'service is up.'
text:
'Hook execution failed: Exception from'
end
end
spec/models/hooks/web_hook_spec.rb
浏览文件 @
949a7e8e
...
...
@@ -71,5 +71,11 @@ describe ProjectHook do
expect
{
@project_hook
.
execute
(
@data
,
'push_hooks'
)
}.
to
raise_error
(
RuntimeError
)
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录