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
b4abccf9
Commit
b4abccf9
authored
Jul 30, 2021
by
Luke Duncalfe
Committed by
Nikola Milojevic
Aug 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs web hook url validations
parent
9ff18ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+15
-0
spec/models/hooks/web_hook_spec.rb
spec/models/hooks/web_hook_spec.rb
+13
-0
No files found.
spec/models/hooks/system_hook_spec.rb
View file @
b4abccf9
...
...
@@ -16,6 +16,21 @@ RSpec.describe SystemHook do
end
end
describe
'validations'
do
describe
'url'
do
let
(
:url
)
{
'http://localhost:9000'
}
it
{
is_expected
.
not_to
allow_value
(
url
).
for
(
:url
)
}
it
'is valid if application settings allow local requests from system hooks'
do
settings
=
ApplicationSetting
.
new
(
allow_local_requests_from_system_hooks:
true
)
allow
(
ApplicationSetting
).
to
receive
(
:current
).
and_return
(
settings
)
is_expected
.
to
allow_value
(
url
).
for
(
:url
)
end
end
end
describe
"execute"
,
:sidekiq_might_not_need_inline
do
let
(
:system_hook
)
{
create
(
:system_hook
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/models/hooks/web_hook_spec.rb
View file @
b4abccf9
...
...
@@ -32,6 +32,19 @@ RSpec.describe WebHook do
it
{
is_expected
.
not_to
allow_value
(
'ftp://example.com'
).
for
(
:url
)
}
it
{
is_expected
.
not_to
allow_value
(
'herp-and-derp'
).
for
(
:url
)
}
context
'when url is local'
do
let
(
:url
)
{
'http://localhost:9000'
}
it
{
is_expected
.
not_to
allow_value
(
url
).
for
(
:url
)
}
it
'is valid if application settings allow local requests from web hooks'
do
settings
=
ApplicationSetting
.
new
(
allow_local_requests_from_web_hooks_and_services:
true
)
allow
(
ApplicationSetting
).
to
receive
(
:current
).
and_return
(
settings
)
is_expected
.
to
allow_value
(
url
).
for
(
:url
)
end
end
it
'strips :url before saving it'
do
hook
.
url
=
' https://example.com '
hook
.
save!
...
...
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