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
7fe145b1
Commit
7fe145b1
authored
Jul 26, 2019
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SystemHookUrlValidator spec
parent
6c42088f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
spec/validators/system_hook_url_validator_spec.rb
spec/validators/system_hook_url_validator_spec.rb
+51
-0
No files found.
spec/validators/system_hook_url_validator_spec.rb
0 → 100644
View file @
7fe145b1
require
'spec_helper'
describe
SystemHookUrlValidator
do
include_examples
'url validator examples'
,
AddressableUrlValidator
::
DEFAULT_OPTIONS
[
:schemes
]
context
'by default'
do
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:link_url
])
}
let!
(
:badge
)
{
build
(
:badge
,
link_url:
'http://www.example.com'
)
}
subject
{
validator
.
validate
(
badge
)
}
it
'does not block urls pointing to localhost'
do
badge
.
link_url
=
'https://127.0.0.1'
subject
expect
(
badge
.
errors
).
not_to
be_present
end
it
'does not block urls pointing to the local network'
do
badge
.
link_url
=
'https://192.168.1.1'
subject
expect
(
badge
.
errors
).
not_to
be_present
end
end
context
'when local requests are not allowed'
do
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:link_url
],
allow_localhost:
false
,
allow_local_network:
false
)
}
let!
(
:badge
)
{
build
(
:badge
,
link_url:
'http://www.example.com'
)
}
subject
{
validator
.
validate
(
badge
)
}
it
'blocks urls pointing to localhost'
do
badge
.
link_url
=
'https://127.0.0.1'
subject
expect
(
badge
.
errors
).
to
be_present
end
it
'blocks urls pointing to the local network'
do
badge
.
link_url
=
'https://192.168.1.1'
subject
expect
(
badge
.
errors
).
to
be_present
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