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
Léo-Paul Géneau
gitlab-ce
Commits
1345968e
Commit
1345968e
authored
Jun 25, 2018
by
Jan Beckmann
Committed by
Rémy Coutable
Jun 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "WebHookService doesn't handle user info with nil passwords"
parent
7da7af3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
app/services/web_hook_service.rb
app/services/web_hook_service.rb
+1
-1
changelogs/unreleased/46571-webhooks-nil-password.yml
changelogs/unreleased/46571-webhooks-nil-password.yml
+5
-0
spec/services/web_hook_service_spec.rb
spec/services/web_hook_service_spec.rb
+30
-0
No files found.
app/services/web_hook_service.rb
View file @
1345968e
...
...
@@ -82,7 +82,7 @@ class WebHookService
post_url
=
hook
.
url
.
gsub
(
"
#{
parsed_url
.
userinfo
}
@"
,
''
)
basic_auth
=
{
username:
CGI
.
unescape
(
parsed_url
.
user
),
password:
CGI
.
unescape
(
parsed_url
.
password
)
password:
CGI
.
unescape
(
parsed_url
.
password
.
presence
||
''
)
}
make_request
(
post_url
,
basic_auth
)
end
...
...
changelogs/unreleased/46571-webhooks-nil-password.yml
0 → 100644
View file @
1345968e
---
title
:
Fix webhook error when password is not present
merge_request
:
19945
author
:
Jan Beckmann
type
:
fixed
spec/services/web_hook_service_spec.rb
View file @
1345968e
...
...
@@ -60,6 +60,36 @@ describe WebHookService do
).
once
end
context
'when auth credentials are present'
do
let
(
:url
)
{
'https://example.org'
}
let
(
:project_hook
)
{
create
(
:project_hook
,
url:
'https://demo:demo@example.org/'
)
}
it
'uses the credentials'
do
WebMock
.
stub_request
(
:post
,
url
)
service_instance
.
execute
expect
(
WebMock
).
to
have_requested
(
:post
,
url
).
with
(
headers:
headers
.
merge
(
'Authorization'
=>
'Basic ZGVtbzpkZW1v'
)
).
once
end
end
context
'when auth credentials are partial present'
do
let
(
:url
)
{
'https://example.org'
}
let
(
:project_hook
)
{
create
(
:project_hook
,
url:
'https://demo@example.org/'
)
}
it
'uses the credentials anyways'
do
WebMock
.
stub_request
(
:post
,
url
)
service_instance
.
execute
expect
(
WebMock
).
to
have_requested
(
:post
,
url
).
with
(
headers:
headers
.
merge
(
'Authorization'
=>
'Basic ZGVtbzo='
)
).
once
end
end
it
'catches exceptions'
do
WebMock
.
stub_request
(
:post
,
project_hook
.
url
).
to_raise
(
StandardError
.
new
(
'Some error'
))
...
...
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